|
Perforce Chronicle 2012.2/486814
API Documentation
|
This is the menu form. More...
Public Member Functions | |
| init () | |
| Defines the elements that make up the menu form. | |
This is the menu form.
| Menu_Form_Menu::init | ( | ) |
Defines the elements that make up the menu form.
Called automatically when the form object is created.
{
// form should use p4cms-ui styles.
$this->setAttrib('class', 'p4cms-ui menu-form');
// set the method for the form to POST
$this->setMethod('post');
// add a field to collect the menu title.
$validator = new P4Cms_Validate_RecordId;
$validator->setAllowForwardSlash(false);
$this->addElement(
'text',
'id',
array(
'label' => 'Id',
'required' => true,
'filters' => array('StringTrim'),
'validators' => array($validator)
)
);
// add a field to collect the menu label.
$this->addElement(
'text',
'label',
array(
'label' => 'Label',
'required' => true,
'filters' => array('StringTrim')
)
);
// add a field to change the order of the menu with respect to other menus
$this->addElement(
'select',
'order',
array(
'label' => 'Order',
'value' => 0,
'description' => "Adjust the position of this menu when managing menus.",
'multiOptions' => array_combine(range(-10, 10), range(-10, 10))
)
);
// add a field to control if this menu is shown when editing content
$this->addElement(
'checkbox',
'showInContentForm',
array(
'label' => 'Show In Content Form',
'value' => false,
'description' => "Show when managing menus via the content form."
)
);
// add the submit button
$this->addElement(
'SubmitButton',
'save',
array(
'label' => 'Save',
'required' => false,
'class' => 'preferred',
'ignore' => true
)
);
// put the button in a fieldset.
$this->addDisplayGroup(
array('save'),
'buttons',
array('class' => 'buttons')
);
}