Over a million developers have joined DZone.
Platinum Partner

How to use Zend Framework's formCheckbox View Helper

· Web Dev Zone

The Web Dev Zone is brought to you by Stormpath—offering a pre-built Identity API for developers. Easily build powerful user management, authentication, and authorization into your web and mobile applications. Download this Forrester report on the new landscape of Customer Identity and Access Management.

I am almost always going back to check the syntax of  formCheckbox Zend Framework View Help so I decided to post it here.
<?php echo $this->formCheckbox('data[enabled]', 1, null, array(1, 0)); ?>
OR
<?php echo $this->formCheckbox('data[enabled]', 1, !empty($this->data['enabled']) ? array('checked' => 1) : null); ?>

The Web Dev Zone is brought to you by Stormpath—offering a pre-built, streamlined User Management API for building web and mobile applications. Check out our top pointers for designing your REST API.

Topics:

Published at DZone with permission of Svetoslav Marinov , DZone MVB .

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}