ZF-706: Cannot specify id attribute for hidden fields in 0.6.0

Description

Prior to ZF 0.6.0 (eg 0.2.0) I could specify the id of hidden fields like:

$this->formHidden($name, $value, array("id" => "theId"));

When moving to ZF 0.6.0 from 0.2.0, the resulting html no longer has the id attribute, which breaks my javascript code.

I have looked at some ZF code briefly and it seems that the function Zend/View/Helper/FormElement::_getInfo is unsetting the id field when creating the $info array, and the _hidden function does not use the $id after extract()'ing that variable, so the id gets lost.

I have temporarily hacked my copy of ZF 0.6.0 to include the id, it also affects formCheckbox, which is also losing the id. I do not know if there are any other cases.

I have not marked this issue as a bug as I dont know if this is by design, but it's certainly breaking my code (that worked on 0.2.0) and I see no reason why I cannot specify an id for a hidden field.

Comments

Resolved in version 2856.

This is still very much broken.

Given my current version of ZF (svn Revision 1546) + the patch here, this code:


 
  $xhtml .= $this->formHidden("line[" . $n . "][id]", 
             $line->id,
             array("id" => "id_" . $s_l)) . "\n";
  $xhtml .= $this->formHidden("line[" . $n . "][type]",
             $line->type,
             array("id" => "type_" . $s_l)) . "\n";
  $xhtml .= $this->formHidden("line[" . $n . "][location]",
             $line->location,
             array("id" => "location_" . $s_l)) . "\n";

results in this output:


You can see that the "id" attribute is picking up the value assigned to "name".

It looks like this may be happening in FormElement::_getInfo() near the top (line 80, or so).


    protected function _getInfo($name, $value = null, $attribs = null, 
        $options = null, $listsep = null)
    {
        // the baseline info.  note that $name serves a dual purpose;
        // if an array, it's an element info array that will override
        // these baseline values.  as such, ignore it for the 'name' 
        // if it's an array.
        $info = array(
            'name'    => is_array($name) ? '' : $name,
            'id'      => is_array($name) ? '' : $name,
            'value'   => $value,
            'attribs' => $attribs,
            'options' => $options,
            'listsep' => $listsep,
            'disable' => false,
        );

Oops, sorry, looks like a misfire on my part. Someone else made an unannounced change in the config that changed the zf library path. Not nice.