Subha
Subha

Reputation: 31

zend form submit button value not showing in zend form

Hi I have a zend form with this code in it

$field = new Zend_Form_Element_Submit('submit');
$field->setAttrib('class', 'btn')->setlabel('Save');        

$this->addElement($field);

but the html comeing is:

<input type="submit" class="btn" helper="formSubmit" value="" id="submit" name="submit">

can't figure out why is the value not showing up?

Upvotes: 2

Views: 1576

Answers (3)

konradwww
konradwww

Reputation: 691

You want to set the value? so use the setter:$field->setValue('Save');

Upvotes: 0

Bolebor
Bolebor

Reputation: 11

Change type (default type="button" don't trigger form submit) to "submit". e.g.

$this->addElement('button', 'my_button', array(
    'label' => 'Click me',
    'class' => 'nice_button',
    'type' => 'submit'
));

Upvotes: 1

000
000

Reputation: 3950

$field->setAttrib('class', 'btn')->setLabel('Save');

please note the capital 'L' in setLabel() above

Upvotes: 2

Related Questions