I create a hidden element that way:
$this->addElement('hidden', 'id', '1');
but what I get is this:
<input type="hidden" name="id" value="" id="id" />
I've also tried like this:
$this->addElement('hidden', 'id', array(
'value' => 1
));
but it didn't work better.
What's wrong?
You might be using
$form->populate($someData);
or
$form->isValid($someData);
somewhere in your code ;)
I think you have to put in your form class:
public function populate(array $values) {
parent::populate($values);
$this->addElement('hidden', 'hidden');
$el = $this->getElement('hidden');
$el->setValue(1);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With