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

Link to comment
Share on other sites

  • 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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.