Zend Framework

Changing default decorators for Zend_Dojo_Form_Element causes setOptions method to be inocuous

Details

  • Type: Bug Bug
  • Status: Open Open
  • Priority: Minor Minor
  • Resolution: Unresolved
  • Affects Version/s: 1.11.11
  • Fix Version/s: None
  • Component/s: Zend_Dojo
  • Labels:
    None

Description

When trying to change the default decorators for a Zend_Dojo_Form_Element_CheckBox the options set in setOptions method are not taken in consideration.

For instance, with Zend_Form_Element_Checkbox using this code:

$closeonsubmit = new Zend_Form_Element_CheckBox('closeonsubmit');
$closeonsubmit->setLabel('Fechar após guardar')
  ->setOptions(array('class' => 'closeonsubmitcheckbox','onClick' => 'SynchCloseOnSubmit(this)'))
  ->setDecorators(array(array('ViewHelper'),array('HtmlTag', array('tag' => 'dd', 'class' => 'closeonsubmit')),
            		array('Label', array('tag'=> 'dt')),));

will render:

<dt id="ownerSubForm-closeonsubmit-label">
  <label for="ownerSubForm-closeonsubmit" class="optional">Fechar após guardar</label>
</dt>
<dd class="closeonsubmit">
  <input type="hidden" name="ownerSubForm[closeonsubmit]" value="0">
  <input type="checkbox" name="ownerSubForm[closeonsubmit]" id="ownerSubForm-closeonsubmit"
         value="1" class="closeonsubmitcheckbox" onClick="SynchCloseOnSubmit(this)">
</dd>

But when using a Dojo element in the same way:

$closeonsubmit = new Zend_Dojo_Form_Element_CheckBox('closeonsubmit');
$closeonsubmit->setLabel('Fechar após guardar')
  ->setOptions(array('class' => 'closeonsubmitcheckbox','onClick' => 'SynchCloseOnSubmit(this)'))
  ->setDecorators(array(array('ViewHelper'),array('HtmlTag', array('tag' => 'dd', 'class' => 'closeonsubmit')),
            		array('Label', array('tag'=> 'dt')),));

will render:

<dt id="headerSubForm-closeonsubmit-label">
  <label for="headerSubForm-closeonsubmit" class="optional">Fechar após guardar</label>
</dt>
<dd class="closeonsubmit">
  <input name="headerSubForm[closeonsubmit]" value="0" type="hidden">
  <input checkedValue="1" uncheckedValue="0" id="headerSubForm-closeonsubmit" 
         name="headerSubForm[closeonsubmit]" value="0" type="checkbox">
</dd>

Notice that the onClick event attribute is missing as the class attribute is also.
I don't think that the behaviour should be different between the two.

Activity

There are no comments yet on this issue.

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated: