I am using a form with subforms to display rows of a database to be
validated.
My subform is very simple: it only contains radio buttons to validate or
delete the row, and the display of two fields.
class My_Form_Subform extends Zend_Form_Subform
{
public function init()
{
$this->addElement('text', 'field1');
$this->getElement('field1')
->setAttrib('disabled', 'disabled');
$this->addElement('text', 'field2');
$this->getElement('field2')
->setAttrib('readonly', 'readonly');
$this->addElement('radio', 'OPERATION');
$this->getElement('OPERATION')
->setMultiOptions(array('D'=>'Delete', 'V'=>'Validate'));
}
}
My controller create a form and add a subform like this:
class IndexController extends Zend_Controller_Action
{
public function indexAction()
{
$data['id'] = 10;
$data['field1'] = 'first field';
$data['field2'] = 'second field';
$data['OPERATION'] = 'V'; //to select automatically the
validate option
$form = new Zend_Form();
$form->addElement('submit', 'Validate');
$subForm = new My_Form_Subform();
$subForm->populate($data);
$form->addSubForm($subForm, $data['id']);
$this->view->form = $form;
}
}
I would like to replace the input text with normal text. Does someone
have any idea how to do that (if possible) ?
Thanks
Ithier
没有评论:
发表评论