-- Denis Fohl <[email protected]> wrote
(on Wednesday, 15 July 2009, 01:08 PM +0200):
> i'm fighting with Zend_Form_Element factory and can't fix the following
> problem (ZF 1.8.4 patch 1):
>
> $fields = array(
> 'id_ue' => array(
> 'type' => 'text',
> 'name' => 'id_ue',
> 'options' => array('label' => 'code UE',
> 'size' => 6,
> 'required' => true,
> 'value' => 'test')),
> 'id_session' => array(
> 'type' => 'hidden',
> 'name' => 'id_session',
> 'options' => array('value' => 'test'))
> );
>
> $form = new Zend_Form();
> $form->addElements($fields);
>
> When rendering the form, all seems right but values are not set in input
> tags :
>
> <input type="text" size="6" value="" id="id_ue" name="id_ue"/>
> <input type="hidden" id="id_session" value="" name="id_session"/>
>
> I have tried a lot of things (setting value outside of 'options', using
> 'attrib' in options but don't the syntax...).
> I did not find any examples of this use case.
Odd -- I took your above code, and added the following two lines:
$form->setView(new Zend_View);
echo $form;
And got the expected output:
<form enctype="application/x-www-form-urlencoded" action=""
method="post"><dl class="zend_form">
<dt id="id_ue-label"><label for="id_ue" class="required">code
UE</label></dt>
<dd id="id_ue-element">
<input type="text" name="id_ue" id="id_ue" value="test" size="6"></dd>
<dt id="id_session-label"> </dt>
<dd id="id_session-element">
<input type="hidden" name="id_session" value="test"
id="id_session"></dd></dl></form>
Note that the values are appropriately set.
What version of ZF are you using? Do you call setDefaults() or
populate() at any point?
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/