diff --git a/modules/backend/classes/FormTabs.php b/modules/backend/classes/FormTabs.php index 45a5af56e..4776a496f 100644 --- a/modules/backend/classes/FormTabs.php +++ b/modules/backend/classes/FormTabs.php @@ -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 diff --git a/modules/backend/widgets/Form.php b/modules/backend/widgets/Form.php index d4d349518..2c3968d3e 100644 --- a/modules/backend/widgets/Form.php +++ b/modules/backend/widgets/Form.php @@ -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. */