Perforce Chronicle 2012.2/486814
API Documentation

Menu_Form_MenuItemContent Class Reference

This form is specialized for content menu items and provides a content reference element and label enhancements. More...

Inheritance diagram for Menu_Form_MenuItemContent:
Menu_Form_MenuItem P4Cms_Form Menu_Form_MenuItemContentQuick

List of all members.

Public Member Functions

 init ()
 Defines the elements that make up the content menu item form.
 setDefaults ($defaults)
 Extends parent to deal with enabling/disabling label field based on use of content's title.

Protected Member Functions

 _updateLabel ()
 Get javascript code to update the label input from the content reference element.

Detailed Description

This form is specialized for content menu items and provides a content reference element and label enhancements.

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_MenuItemContent::_updateLabel ( ) [protected]

Get javascript code to update the label input from the content reference element.

Returns:
string the js to update the label.
    {
        return "var label = dojo.query('input[name=label]',                    this.form)[0];"
             . "var title = dojo.query('input[name=contentId-title]',          this.form)[0];"
             . "var auto  = dojo.query('input[name=autoLabel][type=checkbox]', this.form)[0];"
             . "if (auto.checked) {"
             . "    label.value = title.value;"
             . "}";
    }
Menu_Form_MenuItemContent::init ( )

Defines the elements that make up the content menu item form.

Called automatically when the form object is created.

Reimplemented from Menu_Form_MenuItem.

Reimplemented in Menu_Form_MenuItemContentQuick.

    {
        parent::init();

        // distinguish this form from other menu item forms for styling.
        $this->setAttrib('class', $this->getAttrib('class') . ' menu-item-content-form');

        // make the title optional and add a description
        $this->getElement('label')
             ->setRequired(false);

        $this->addElement(
            'checkbox',
            'autoLabel',
            array(
                'label'     => "Use content entry's title",
                'order'     => -35,
                'value'     => true,
                'ignore'    => true,
                'onClick'   => $this->_updateLabel()
                            .  "if (this.checked) {"
                            .  "    dojo.attr(label, 'disabled', 'true');"
                            .  "} else {"
                            .  "    dojo.removeAttr(label, 'disabled');"
                            .  "}"
            )
        );

        // adjust how the auto-label element is decorated
        // to put the label immediately after the checkbox.
        $element = $this->getElement('autoLabel');
        static::moveCheckboxLabel($element);

        // add a content reference field
        $this->addElement(
            'contentSelect',
            'contentId',
            array(
                'label'     => 'Entry',
                'required'  => true,
                'onChange'  => $this->_updateLabel(),
                'onLoad'    => $this->_updateLabel()
            )
        );

        $this->addElement(
            'select',
            'contentAction',
            array(
                'label'         => "Action",
                'required'      => true,
                'multiOptions'  => array(
                    'view'      => 'Go To Page',
                    'image'     => 'View Image',
                    'download'  => 'Download File'
                )
            )
        );
    }
Menu_Form_MenuItemContent::setDefaults ( defaults)

Extends parent to deal with enabling/disabling label field based on use of content's title.

Parameters:
P4Cms_Record | array$defaultsthe default values to set on elements
Returns:
Zend_Form provides fluent interface

Reimplemented from Menu_Form_MenuItem.

Reimplemented in Menu_Form_MenuItemContentQuick.

    {
        parent::setDefaults($this->combineType($defaults));

        $noTitle = strlen($this->getValue('label')) <= 0;

        $this->getElement('label')
             ->setAttrib('disabled', $noTitle ?: null);

        $this->getElement('autoLabel')
             ->setValue($noTitle);

        return $this;
    }

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