Our blog
Zend Form Disable Fields
I use this little function as part of my base form class to enable me to easily lock certain form elements.
-
public function lockField($field){
-
$elem = $this->getElement($field);
-
$elem->setAttrib('disabled', true);
-
$elem->setAttrib('readonly',true);
-
}
usage might be like the following:
-
public function makeForm($action){
-
$form->addElement(.. custom form add element function);
-
$form->lockField('fieldname');
-
$form->addSubmit(.. custom add submit function);
-
return $form;
-
}
More Reading:
3 Comments
|
How could you attach this functionality to a check box? Eg. You have a form with check boxes. When you click a check box you want it to display a text box element. An example is where you are trying to find out how a customer came to your page. |
|
I think you would be best approaching that with javascript. you could use this function to lock the textbox and then use javascript to unlock and hide it. |
|
Think that this page explain it: |
RSS Feed
Jeremy
September 9th, 2009