ZF2-457: Fatal error: Call to undefined method Zend\Form\Element::getCheckedValue() in Zend\Form\View\Helper\FormCheckbox.php on line 48

Issue Type: Bug Created: 2012-08-09T15:23:34.000+0000 Last Updated: 2012-08-18T09:23:29.000+0000 Status: Resolved Fix version(s): Reporter: Zion Ng (kitthrng) Assignee: Matthew Weier O'Phinney (matthew) Tags: - Zend\Form

  • Zend\Form\Element\Checkbox
  • checkbox
  • formCheckbox

Related issues: Attachments:


Got the error shown in Summary when using the formCheckbox helper to render a checkbox. Tested against zendframework-zf2-release-2.0.0rc2-86-g8fb1930

<pre class="highlight">
// sample form
namespace Web\Form;
use Zend\Form\Form;
class Test extends Form
    public function __construct($name = null)

        $this->setAttribute('method', 'post');

            'name' => 'testcheck',
            'attributes' => array(
                'type' => 'checkbox',
                'checked' => false,
            'options' => array(
                'label' => 'Test option',

<pre class="highlight">
// sample controller
public testAction()
    $form = new \Web\Form\Test();
    return array('form' => $form);

<pre class="highlight">
// sample view script
<?php echo $this->formCheckbox($form->get('testcheck')); ?>


Posted by Chris Martin (cgmartin) on 2012-08-12T14:05:11.000+0000

The formCheckbox helper requires that the Element is of type Zend\Form\Element\Checkbox in order to get extra information for rendering the checkbox (checked, unchecked, useHiddenElement values).

Added PR to ensure that Checkbox Element is used:

Downgrading issue from Blocker to Major since there is a workaround via Zend\Form\Element\Checkbox.

Posted by Maks 3w (maks3w) on 2012-08-18T09:23:29.000+0000

Patch merged

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.