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 677031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:59:39+00:00 2026-05-14T00:59:39+00:00

I am working on zend. I have a form with some checkboxes. I want

  • 0

I am working on zend. I have a form with some checkboxes. I want to get data from database and populate this data to this form. If ‘1’ is stored in table field then tick the check box otherwise leave it alone. In textboxes and dropdowns, data is easily populated but how to check a checkbox in action.

I am creating checkboxes and textboxes elements like this in form.php:

// Person name
$person = $this->CreateElement('text', 'name');
$person->setLabel('Name');
$elements[] = $person;    

// Organization name
$person = $this->CreateElement('text', 'organization');
$person->setLabel('Organization');
$elements[] = $person;       

// isAdmin Checkbox
$isAdmin = $this->CreateElement('checkbox', 'isAdmin');
$isAdmin->setLabel('Admin');
$elements[] = $isAdmin;

$this->addElements($elements);
$this->setElementDecorators(array('ViewHelper'));

// set form decorator (what script will render the form)
$this->setDecorators(array(array('ViewScript' , array('viewScript' => 'organization/accessroles-form.phtml'))));

How I render a form:

<form name="myform" action="<?= $this->element->getAction() ?>" method="<?= $this->element->getMethod() ?>" id="accessrolesform">

<table align="center" width="100%" border="0"><tbody>

<tr>
    <td><?= $this->element->name ?></td>
</tr>

<tr>
    <td><?= $this->element->organization ?></td>
</tr>


<tr>
    <td><?= $this->element->isAdmin ?></td>
</tr>

</table>
</form>

And populating data like this (for example):

// Prepare data to populate
$data['name'] = 'Naveed';
$data['organization'] = 'ABC';
$data['isAdmin'] = '1';

// Populate editable data
$this->view->form->populate( $data );

It is populating data in textboxes but not checking the checkbox? Any idea that how to check a checkbox from action?

Thanks

  • 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-14T00:59:39+00:00Added an answer on May 14, 2026 at 12:59 am

    From the manual:

    By default, the checked value is ‘1’,
    and the unchecked value ‘0’. You can
    specify the values to use using the
    setCheckedValue() and
    setUncheckedValue() accessors,
    respectively. Additionally, setting
    the value sets the checked property of
    the checkbox. You can query this using
    isChecked() or simply accessing the
    property. Using the setChecked($flag)
    method will both set the state of the
    flag as well as set the appropriate
    checked or unchecked value in the
    element. Please use this method when
    setting the checked state of a
    checkbox element to ensure the value
    is set properly.

    $checkboxElement->setChecked(true);
    

    will set the value of the checkbox to ‘checked=”checked” with a value of “1”.

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

Sidebar

Related Questions

I am working with Zend Framework. I have a form with some fields, all
I am working with zend just recently. I discovered this ViewScript decorator for form
I'm working within zend forms. Currently this is how it looks: I want to
I'm doing this tutorial: http://www.phpeveryday.com/articles/Zend-Framework-Database-Creating-Input-Form-P494.html We are building a simple input form using POST
I have working user registration form. It consist of Zend Form Elements. Now I
I am working on a Zend Framework application with PHP. I have a form
I have the zend javabridge working. Now I want to call a .jar file
I have created a zend form. I have added some elements. I have put
I have a working zend mvc application that is using a layout, and this
I have been working with Zend for a few months now and am at

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.