Issue #52 resolved

CHtml::resolveName() is called twice on single attribute

SlKelevro
created an issue

CHtml::resolveName() is called twice on $this->attribute in both BootInputHorizontal and BootInputVertical widgets (methods checkBox() and radioButton()). First time - explicitly (line 37, BootInputVertical), second call is implicit (inside the CHtml::activeRadioButton()). Thus, writing {{{

!php

echo $form->checkBoxRow($detail, "[show_help]value"); }}} will result in this html code: {{{

!html

<label class="checkbox" for="UserDetail_show_help_value"> <input id="ytUserDetail_value" type="hidden" value="0" name="UserDetail[value]"> <input name="UserDetail[value]" id="UserDetail_value" value="1" type="checkbox"> Show hints</label> }}} when expected: {{{

!html

<label class="checkbox" for="UserDetail_show_help_value"> <input id="ytUserDetail_show_help_value" type="hidden" value="0" name="UserDetail[show_help][value]"> <input name="UserDetail[show_help][value]" id="UserDetail_show_help_value" value="1" type="checkbox"> Show hints</label> }}} Suggested fix (this is for BootInputVertical::checkBox()): add additional variable $attibute = $this->attribute. Next code should replace lines 37-40: {{{

!php

$attribute = $this->attribute; echo '<label class="checkbox" for="'.CHtml::getIdByName(CHtml::resolveName($this->model, $attribute)).'">'; echo $this->form->checkBox($this->model, $this->attribute, $this->htmlOptions).PHP_EOL; echo $this->model->getAttributeLabel($attribute); }}}

ps. Would fork to fix, but I don't use mercurial :)

Comments (2)

  1. Log in to comment