Reputation: 393
I'm looking for a way that I can add my zend form element inside a table, I tried this method below but its not working:I want this element to be inside the table below it.example pic below
$name2 = new Zend_Form_Element_Text('search');
$name2->setLabel('Search Enterprise Name:');
$name2->addValidator('NotEmpty')
->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'table', 'id' => 't1')), 'Form',
));
<div class="col-md-6" style="margin-left: 0;">
<table class='spreadsheet dataTable' cellpadding='0' cellspacing='' id="t1">
<thead>
<tr role="row">
<th>ENTER SERVICE PROVIDER USED</th>
</tr>
</thead>
</table>
<button type="button" onclick="alert('I work!')">Click Me!</button>
</div>
Thanks in advance
Upvotes: 1
Views: 353
Reputation: 5772
If I understand the question correctly, you can add the item into view.
Declare your item in a form Application_Form_Toto
.
In your action to declare your form in the view
$form = new Application_Form_Toto();
$this->view->form = $form;
Call your element in your HTML (your view)
<table>...<tr>...<td><?php echo $this->form->search;?></td>...</tr>...</table>
Upvotes: 1
Reputation: 326
If you just want to retrieve the single element from the form file then,
class Form_Test() {
public function init() {
$name2 = new Zend_Form_Element_Text('search');
$name2->setLabel('Search Enterprise Name:');
$name2->addValidator('NotEmpty')
->setDecorators(array(
'FormElements',
array('HtmlTag', array('tag' => 'table', 'id' => 't1')), 'Form',
));
}
}
In the controller file:
$form = new Form_test();
$this->view->form = $form;
In the view file you can call the single element only as,
<table>...<tr>...<td><?php echo $this->form->getElement("search");?></td>...</tr>...</table>
Also, if you do not want your design to be controlled from decorators, you can simply call removeDecorator() in form and adjust your design from view itself with this method.
Upvotes: 0