Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4575502
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T20:04:23+00:00 2026-05-21T20:04:23+00:00

I want to populate the form with multicheckboxes and the multicheckboxes are grouped together,

  • 0

I want to populate the form with multicheckboxes and the multicheckboxes are grouped together, so if I have a multi check box checked, I will view them all. The normal populate is not working. It just gets me one of the checkboxes. This is my code.

public function addEditAction() {


    $id = (int) $this->_request->getParam('id');

    $request = $this->getRequest();

    $form = new Admin_Form_Tab();

    $db = Zend_Db_Table::getDefaultAdapter();

    if ($this->getRequest()->isPost()) {
        if ($form->isValid($request->getPost())) {
            if (isset($id) && $id != "") {
                $gettag = $form->getValue('tag_id');
                $gettags = count($gettag);
                try {
                    //shift the orders to
                    $select = $db->select()->from(array('t' => 'tab'), array('t.id',
                                't.title',
                                't.tab_position',
                                't.order',
                                't.is_active',
                                't.is_deleted'))->where('id = ?', $id);
                    $currentTab = $db->fetchRow($select);
                    $var3 = array('tab.order' => new Zend_Db_Expr('tab.order - 1'));
                    $var4 = array('tab.order >= ' . $currentTab['order'], 'is_active=1', 'is_deleted=0', 'tab_position=1');
                    $db->update('tab', $var3, $var4);
                    $var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
                    $var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=1');
                    $db->update('tab', $var, $var2);
                    $db->delete('tab_tag', array('tab_id = ?' => $id));
                    foreach ($gettag as $value) {

                        $db->insert('tab_tag',
                                array(
                                    'tag_id' => $value,
                                    'tab_id' => $id
                        ));
                    }
                    $db->update('tab', array(
                        'title' => $form->getValue('title'),
                        'body' => $form->getValue('body'),
                        'is_active' => $form->getValue('is_active'),
                        'banner_link' => $form->getValue('banner_link'),
                        'tab_path' => $form->getValue('tab_path'),
                        'link_open' => $form->getValue('link_open'),
                        'tab_position' => $form->getValue('tab_position'),
                        'tab_parent' => $form->getValue('tab_parent')
                            ),
                            array('id =?' => $id));
                    $this->flash('Tab Updated', 'admin/tab');
                } catch (Exception $e) {

                    $this->flash($e->getMessage(), 'admin/tab');
                }
            } else {
                try {
                    $formValues = $form->getValues();
                    $formValues['created_by'] = 1;
                    $formValues['created_date'] = date('Y/m/d H:i:s');
                    $formValues['is_deleted'] = 0;

                    $var = array('tab.order' => new Zend_Db_Expr('tab.order + 1'));
                    $var2 = array('tab.order >= ' . $form->getValue('order'), 'is_active=1', 'is_deleted=0', 'tab_position=1');
                    $db->update('tab', $var, $var2);

                    foreach ($gettag as $value) {

                        $db->insert('tab_tag',
                                array(
                                    'tag_id' => $value,
                                    'tab_id' => $id
                        ));
                    }
                    $db->insert('tab', array(
                        'title' => $form->getValue('title'),
                        'body' => $form->getValue('body'),
                        'is_active' => $form->getValue('is_active'),
                        'banner_link' => $form->getValue('banner_link'),
                        'tab_path' => $form->getValue('tab_path'),
                        'link_open' => $form->getValue('link_open'),
                        'tab_position' => $form->getValue('tab_position'),
                        'tab_parent' => $form->getValue('tab_parent')
                    ));




                    $this->flash('Tab inserted', 'admin/tab');
                } catch (Exception $e) {
                    $this->flash($e->getMessage(), 'admin/tab');
                }
            }
        }
    }
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */


    if (isset($id) && $id != "") {
        $values = $db->fetchRow($db->select()
                ->from(array('t'=>'tab'))
                ->joinLeft(array('tt'=>'tab_tag'), 'tt.tab_id = t.id'));
        $form->populate($values);
    }

    $this->view->form = $form;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T20:04:23+00:00Added an answer on May 21, 2026 at 8:04 pm

    To populate multicheckbox you have to provide array with the key of checkboxes that has to be checked:

    $values = array(
        'my_mylticheckbox' => array(1,3,5)
    );
    $form->populate($values);
    

    or if you want to make checked only one checkbox:

    $values = array('my_multicheckbox' => 3);
    $form->populate($values);
    

    So, just make sure you pass an array as the value for you multicheckbox.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say we have a form field and want to populate it with a images
Actually I want to populate an array to fill up my table view, but
I have a UITableView which I want to populate with details from an array
I want to dynamically populate a form field from multiple other fields in the
I want to automatically populate a hidden form element with the value of what
I populate web form with dynamic list of exams from database. I want user
So I have a form that I want the user to use to update
Using jQuery/jQueryUI I want to populate a form using this HTML/JS show below. The
I have a JqGrid that a i want to populate with Json data that
I'm wondering how I can populate a text box in my view from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.