Jump to content

Zend Form - Setting up the form with Multicheckbox


ranjuvs

Recommended Posts

Any one who is familiar with Zend framework please help me

 

I need to set up a form using Zend form. And I need to implement check box with multiple options.

 

$area = $form->createElement('multiCheckbox', 'area_type');
$area->setLabel('Type of Area:');
$area->addMultiOption('1', 'Shopping district (individual shops on a street)');
$area->addMultiOption('2', 'Shopping mall');
$area->addMultiOption('3', 'Mini-mall');
$area->addMultiOption('4', 'Airport shop');
$area->addMultiOption('5', 'Other');

 

I need to make couple of checkboxes checked while the form is loaded. How can I do that. If I set the value of area_type in database as any of the values, then it shows as checked. I want multiple items to be checked

 

Thanks in advance

  • 2 years later...

Example:

$area = $form->createElement('multiCheckbox', 'area_type');
$area->setLabel('Type of Area:');
$area->addMultiOption('1', 'Shopping district (individual shops on a street)');
$area->addMultiOption('2', 'Shopping mall');
$area->addMultiOption('3', 'Mini-mall');
$area->addMultiOption('4', 'Airport shop');
$area->addMultiOption('5', 'Other');

$area->setValue(array('2', '5')); // Selects area 2 and 5

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.