Setting errorOptions results in exception

Issue #86 resolved
Munjal Dhamecha
created an issue

I have a requirement where custom names are needed for common variable in a model in different scenarios, and hence I also set inputID for errors for appropriate client side validation.

Thus I tried setting errorOptions after going through implementation of textFieldRow.

While investigating I noticed that htmlOptions for textField should not be having any nested array. Since getError() is called after textField (or actual control rendering), the errorOptions is not unset from htmlOptions and thus generates exception.


{{{ htmlspecialchars() expects parameter 1 to be string, array given }}}

Example code: {{{


echo $form->textFieldRow($field, 'attr', array( 'labelOptions' => array( 'for' => $field->getLabelFor(), 'label' => $field->getLabel(), ), 'name' => $field->getElementName(), 'id' => $field->getElementId(), 'class' => 'input-xlarge', 'rel' => 'tooltip', 'title' => isset($field->attributeConfig['ui']['hint']) ? $field->attributeConfig['ui']['hint'] : null, 'errorOptions' => array( 'inputID' => $field->getElementId(), ), ));


Comments (6)

  1. Munjal Dhamecha reporter

    What do you think about following approach?

    During initialization of BootInput, parse htmlOptions and extract various other embedded option arrays like (errorOptions, labelOptions, appendOptions, prependOptions and so on) and store them in a protected variable _htmlOptions or other one named relevantly.

    Then this hidden variable can be used freely & directly, without worrying about unsetting any of the sub-array.

  2. NordLabs

    While that would work it's not very yiish to do so. So I'd prefer the current approach at least for now.

    This issue should have been fixed in the default branch. Please let me know if the problem still exists.

  3. Log in to comment