« Return to Thread: Conditionally Setting Zend_Form_Element_Submit

Conditionally Setting Zend_Form_Element_Submit

by KennethS :: Rate this Message:

Reply to Author | View in Thread

Hi,

I have been struggling with this today and thought someone might have some insights.

I have a form that I have built using Zend_Form.  The form can be used to add or edit a record but I need to change the label of the Zend_Form_Element_Submit button depending on which of the two it is.  So either "Add Record" or "Edit Record".  I have tried setting passing a variable to the form but I get a warning that I can't overload the form.  I have also tried setting a variable in the parent view and then referencing it from the form but that didn't work.

I am sure the answer to this is easy but for some reason the routes I have tried are not working.

Any suggesting?

In the form I was hoping to do the following

// form code
.
.
.

if ($actionName = "add") {
  $submitLabel = "Add Record";
} else {
  $submitLabel = "Edit Record";
}

$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton')
           ->setLabel($submitLabel);



Thanks for the help,

Kenneth

 « Return to Thread: Conditionally Setting Zend_Form_Element_Submit