Perforce Chronicle 2012.2/486814
API Documentation

Url_Form_Content Class Reference

A sub-form intended for use with content forms. More...

Inheritance diagram for Url_Form_Content:
P4Cms_Form_SubForm

List of all members.

Public Member Functions

 init ()
 Defines the elements that make up the content url form.
 setDefaults (array $defaults)
 Make path field read only when auto is selected.

Detailed Description

A sub-form intended for use with content forms.

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

Url_Form_Content::init ( )

Defines the elements that make up the content url form.

Called automatically when the form object is created.

    {
        // set the title of this form.
        $this->setLegend('URL');

        // field to capture url path, filtered to strip leading/trailing 
        // slashes and to normalize special character encoding.
        $this->addElement(
            'text',
            'path',
            array(
                'label'         => 'Path', 
                'filters'       => array(new Url_Filter_UrlPath)
            )
        );

        $this->addElement(
            'radio',
            'auto',
            array(
                'value'         => 'true',
                'multiOptions'  => array(
                    'true'  => 'Use Title for URL',
                    'false' => 'Custom'
                ),
                'onClick'       => "
                    var query   = '[dojoType=p4cms.content.SubForm]';
                    var subForm = dijit.byNode(new dojo.NodeList(this).closest(query)[0]);
                    var entry   = subForm.contentEntry;
                    var path    = dojo.query('input[name*=\'url[path]\']', this.form)[0];
                    if (path) {
                        dojo.attr(path, 'readOnly', this.value === 'true');
                    }
                    if (this.value === 'true') {
                        dojo.attr(path, 'value', p4cms.url.autoGenerate(entry));
                    }
                "
            )
        );
        $this->getElement('auto')->removeDecorator('label');
    }
Url_Form_Content::setDefaults ( array $  defaults)

Make path field read only when auto is selected.

Parameters:
array$defaultsthe values to set on the form
Returns:
Zend_Form provides fluent interface
    {
        parent::setDefaults($defaults);
        
        if ($this->getValue('auto') === 'true') {
            $this->getElement('path')->setOptions(array('readOnly' => true));
        }
    }

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