Minor touch ups

This commit is contained in:
Samuel Georges 2015-02-12 08:37:24 +11:00
parent 77d0d25f64
commit 2b32fc4718
2 changed files with 41 additions and 37 deletions

View File

@ -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

View File

@ -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.
*/