mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Minor touch ups
This commit is contained in:
parent
77d0d25f64
commit
2b32fc4718
@ -83,10 +83,25 @@ class FormTabs implements IteratorAggregate, ArrayAccess
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a field to the collection of tabs.
|
||||
* @param string $name
|
||||
* @param FormField $field
|
||||
* @param string $tab
|
||||
*/
|
||||
public function addField($name, FormField $field, $tab = null)
|
||||
{
|
||||
if (!$tab) {
|
||||
$tab = Lang::get('backend::lang.form.undefined_tab');
|
||||
}
|
||||
|
||||
$this->fields[$tab][$name] = $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a field from all tabs by name.
|
||||
* @param string $name
|
||||
* @return True on success, False on failure
|
||||
* @return boolean
|
||||
*/
|
||||
public function removeField($name)
|
||||
{
|
||||
@ -103,21 +118,6 @@ class FormTabs implements IteratorAggregate, ArrayAccess
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a field to the collection of tabs.
|
||||
* @param string $name
|
||||
* @param FormField $field
|
||||
* @param string $tab
|
||||
*/
|
||||
public function addField($name, FormField $field, $tab = null)
|
||||
{
|
||||
if (!$tab) {
|
||||
$tab = Lang::get('backend::lang.form.undefined_tab');
|
||||
}
|
||||
|
||||
$this->fields[$tab][$name] = $field;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array of the registered fields, without tabs.
|
||||
* @return array
|
||||
|
@ -459,27 +459,6 @@ class Form extends WidgetBase
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Programatically remove a field.
|
||||
* @return True on success, False on failure
|
||||
*/
|
||||
public function removeField($name)
|
||||
{
|
||||
if (!isset($this->fields[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Remove from tabs
|
||||
$this->primaryTabs->removeField($name);
|
||||
$this->secondaryTabs->removeField($name);
|
||||
$this->outsideTabs->removeField($name);
|
||||
|
||||
// Remove from form
|
||||
unset($this->fields[$name]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Programatically add fields, used internally and for extensibility.
|
||||
*/
|
||||
@ -526,6 +505,31 @@ class Form extends WidgetBase
|
||||
return $this->addFields($fields, 'secondary');
|
||||
}
|
||||
|
||||
/**
|
||||
* Programatically remove a field.
|
||||
* @return boolean
|
||||
*/
|
||||
public function removeField($name)
|
||||
{
|
||||
if (!isset($this->fields[$name])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/*
|
||||
* Remove from tabs
|
||||
*/
|
||||
$this->primaryTabs->removeField($name);
|
||||
$this->secondaryTabs->removeField($name);
|
||||
$this->outsideTabs->removeField($name);
|
||||
|
||||
/*
|
||||
* Remove from main collection
|
||||
*/
|
||||
unset($this->fields[$name]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a form field object from name and configuration.
|
||||
*/
|
||||
|
Loading…
x
Reference in New Issue
Block a user