Hi,
I'm trying to create an entry page which shows all entries in a database
table. To be able to activate or de-activate an entry, I created a checkbox
in a form using Zend_form. In the view I display each entry and render the
form, using a foreach loop. Somehow I need to set the values of the
checkboxes according to the value of the active field in the table rows. But
I can't get it to work. Below you see the form class:
class eCMS_Form_Active extends eCMS_Form{
public function init(){
$this->addElement('checkbox', 'active',
array(
'decorators' => $this->_cleanElementDecorator,
'required' => true
)
);
}
}
Here's the Controller part (this is set in the indexAction() ):
$form = new eCMS_Form_Active;
$form->getElement('active')->setAttrib('onClick',
'ajx_setActiveState(this);');
$this->view->activeForm = $form;
And this is the foreach loop in the view:
<?
$row_count = 0;
foreach($this->pages as $row){
$trclass = ($row_count % 2) ? 'class="alternative"' : '';
?>
<tr id="id_<?=$row['id']?>" <?=$trclass?>>
<td width="10" class="tdborder">
<?
$this->activeForm->getElement('active')->setAttrib('id',
'active_'.$row['id']);
$this->activeForm->getElement('active')->setAttrib('name',
'active_'.$row['id']);
$this->activeForm->getElement('active')->setAttrib('value', 'TEST');
$this->activeForm->render();
?>
</td>.....
When looking at the sourcecode in the browser, no checkbox element has the
value "TEST". And also the name attribute is not changed. The id attribute
however is changed.
Can anyone tell me if my approach is right, and what needs to be done to
make this work correctly?
Thanks.
--
View this message in context:
http://www.nabble.com/Entrylist-with-checkbox-form%2C-setting-checkbox-values-tp18340413p18340413.html
Sent from the Zend Framework mailing list archive at Nabble.com.