Perforce Chronicle 2012.2/486814
API Documentation

Menu_Form_Menu Class Reference

This is the menu form. More...

Inheritance diagram for Menu_Form_Menu:
P4Cms_Form

List of all members.

Public Member Functions

 init ()
 Defines the elements that make up the menu form.

Detailed Description

This is the menu form.

Copyright:
2011-2012 Perforce Software. All rights reserved
License:
Please see LICENSE.txt in top-level folder of this distribution.
Version:
2012.2/486814

Member Function Documentation

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')
        );
    }

The documentation for this class was generated from the following file: