Make use if 'ignore´ instead of explicitly unsetting array keys

refs #5525
This commit is contained in:
Johannes Meyer 2014-08-12 13:57:28 +02:00
parent e6bcda260d
commit fe63ce664f
11 changed files with 32 additions and 42 deletions

View File

@ -57,6 +57,7 @@ class LoginForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Login') 'label' => t('Login')
) )
); );

View File

@ -20,6 +20,7 @@ abstract class BaseBackendForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );
@ -75,9 +76,6 @@ abstract class BaseBackendForm extends Form
$values = $this->getValues(); $values = $this->getValues();
$name = $values['name']; $name = $values['name'];
unset($values['name']); unset($values['name']);
unset($values['btn_submit']);
unset($values['force_creation']);
unset($values[$this->getTokenElementName()]);
return array($name, $values); return array($name, $values);
} }
@ -104,6 +102,7 @@ abstract class BaseBackendForm extends Form
'force_creation', 'force_creation',
array( array(
'order' => 0, 'order' => 0,
'ignore' => true,
'label' => t('Force Changes'), 'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation') 'helptext' => t('Check this box to enforce changes without connectivity validation')
) )

View File

@ -28,6 +28,7 @@ class ConfirmRemovalForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Confirm Removal') 'label' => t('Confirm Removal')
) )
); );

View File

@ -46,6 +46,7 @@ class GeneralForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );

View File

@ -134,6 +134,7 @@ class LoggingForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save') 'label' => t('Save')
) )
); );
@ -141,21 +142,6 @@ class LoggingForm extends Form
return $this; return $this;
} }
/**
* Retrieve all form element values
*
* Returns all configuration relevant element values.
*
* @return array
*/
public function getValues()
{
$values = parent::getValues();
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return $values;
}
/** /**
* Return the default logging directory for type "file" * Return the default logging directory for type "file"
* *

View File

@ -83,6 +83,7 @@ class ResourceForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );
@ -197,9 +198,6 @@ class ResourceForm extends Form
$values = $this->getValues(); $values = $this->getValues();
$name = $values['name']; $name = $values['name'];
unset($values['name']); unset($values['name']);
unset($values['btn_submit']);
unset($values['force_creation']);
unset($values[$this->getTokenElementName()]);
return array($name, $values); return array($name, $values);
} }
@ -228,6 +226,7 @@ class ResourceForm extends Form
'force_creation', 'force_creation',
array( array(
'order' => 0, 'order' => 0,
'ignore' => true,
'label' => t('Force Changes'), 'label' => t('Force Changes'),
'helptext' => t('Check this box to enforce changes without connectivity validation') 'helptext' => t('Check this box to enforce changes without connectivity validation')
) )

View File

@ -56,6 +56,7 @@ class AddUrlForm extends Form
'submit', 'submit',
'use_existing_dashboard', 'use_existing_dashboard',
array( array(
'ignore' => true,
'label' => t('Use An Existing Pane'), 'label' => t('Use An Existing Pane'),
'style' => 'display: inline-block' 'style' => 'display: inline-block'
) )
@ -76,6 +77,7 @@ class AddUrlForm extends Form
'submit', 'submit',
'create_new_pane', 'create_new_pane',
array( array(
'ignore' => true,
'label' => t('Create A New Pane'), 'label' => t('Create A New Pane'),
'style' => 'display: inline-block' 'style' => 'display: inline-block'
) )
@ -103,6 +105,7 @@ class AddUrlForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Add To Dashboard') 'label' => t('Add To Dashboard')
) )
); );

View File

@ -138,6 +138,7 @@ class GeneralForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );

View File

@ -216,6 +216,7 @@ class Form extends Zend_Form
'hidden', 'hidden',
$this->tokenElementName, $this->tokenElementName,
array( array(
'ignore' => true,
'value' => $this->generateCsrfToken() 'value' => $this->generateCsrfToken()
) )
); );

View File

@ -74,6 +74,7 @@ class BackendForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );
@ -98,8 +99,6 @@ class BackendForm extends Form
} }
unset($values['name']); unset($values['name']);
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return array($name, $values); return array($name, $values);
} }

View File

@ -33,6 +33,7 @@ class InstanceForm extends Form
'type', 'type',
array( array(
'required' => true, 'required' => true,
'ignore' => true,
'label' => t('Instance Type'), 'label' => t('Instance Type'),
'class' => 'autosubmit', 'class' => 'autosubmit',
'helptext' => t( 'helptext' => t(
@ -92,6 +93,7 @@ class InstanceForm extends Form
'hitchhiker', 'hitchhiker',
array( array(
'required' => true, 'required' => true,
'ignore' => true,
'value' => 'Arthur' 'value' => 'Arthur'
) )
); );
@ -119,6 +121,7 @@ class InstanceForm extends Form
'submit', 'submit',
'btn_submit', 'btn_submit',
array( array(
'ignore' => true,
'label' => t('Save Changes') 'label' => t('Save Changes')
) )
); );
@ -138,10 +141,6 @@ class InstanceForm extends Form
$values = $this->getValues(); $values = $this->getValues();
$name = $values['name']; $name = $values['name'];
unset($values['name']); unset($values['name']);
unset($values['type']);
unset($values['hitchhiker']);
unset($values['btn_submit']);
unset($values[$this->getTokenElementName()]);
return array($name, $values); return array($name, $values);
} }