Perforce Chronicle 2012.2/486814
API Documentation
|
A sub-form intended for use with content forms. More...
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. |
A sub-form intended for use with content forms.
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.
array | $defaults | the values to set on the form |
{ parent::setDefaults($defaults); if ($this->getValue('auto') === 'true') { $this->getElement('path')->setOptions(array('readOnly' => true)); } }