<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>CodigoLinea - Benjamin Gonzales &#187; Checkbox error</title>
	<atom:link href="http://codigolinea.com/tag/checkbox-error/feed/" rel="self" type="application/rss+xml" />
	<link>http://codigolinea.com</link>
	<description>Deesarrollo web</description>
	<lastBuildDate>Sat, 28 Nov 2009 14:35:03 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Error en el elemento Checkbox de Zend_Dojo_Form</title>
		<link>http://codigolinea.com/2008/10/10/error-en-el-elemento-checkbox-de-zend_dojo_form/</link>
		<comments>http://codigolinea.com/2008/10/10/error-en-el-elemento-checkbox-de-zend_dojo_form/#comments</comments>
		<pubDate>Fri, 10 Oct 2008 22:04:20 +0000</pubDate>
		<dc:creator>Benjamin Gonzales</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Zend Framework]]></category>
		<category><![CDATA[Checkbox error]]></category>
		<category><![CDATA[Zend Dojo error]]></category>
		<category><![CDATA[Zend_dojo]]></category>
		<category><![CDATA[Zend_Dojo_Form_Element_CheckBox]]></category>

		<guid isPermaLink="false">http://codigolinea.com/?p=20</guid>
		<description><![CDATA[Hoy estuve trabajando con este componente (Zend_Dojo_Form_Element_CheckBox) y me di con la sorpresa de que no funcionaba correctamente. Lo que pasa que hay un pequeño error en  Zend/Dojo/View/Helper/CheckBox.php  el cual no genera correctamente el HTML
Este error afecta a hasta la versión Zend Framework 1.6.1 y aun tampoco se ha solucionado en la versión [...]]]></description>
			<content:encoded><![CDATA[<p>Hoy estuve trabajando con este componente (Zend_Dojo_Form_Element_CheckBox) y me di con la sorpresa de que no funcionaba correctamente. Lo que pasa que hay un pequeño error en <strong> Zend/Dojo/View/Helper/CheckBox.php </strong> el cual no genera correctamente el HTML</p>
<p>Este error afecta a hasta la versión <strong>Zend Framework 1.6.1</strong> y aun tampoco se ha solucionado en la versión de desarrollo.</p>
<p>Veamos un ejemplo</p>
<pre class="brush: php;">
class TestController extends Zend_Controller_Action
{
	function indexAction ()
    {
		$this-&gt;view-&gt;addHelperPath('Zend/Dojo/View/Helper/', 'Zend_Dojo_View_Helper');
		$form = new Zend_Dojo_Form();
		$form-&gt;addElement(
		    'CheckBox',
		    'checkboxValue',
		    array(
		        'label'        =&gt; 'Label',
		        'checkedValue' =&gt; 'checkedValue',
			'uncheckedValue' =&gt; 'notCheckedValue',
		    )
		);

		$form-&gt;addDecorators(array('FormElements', 'Form'));
		$this-&gt;view-&gt;form = $form;
	}
}
</pre>
<p>Esto produce el siguiente HTML:</p>
<pre class="brush: xml;">
&lt;!-- Erroneo//--&gt;
&lt;input name=&quot;checkboxValue&quot; type=&quot;hidden&quot; value=&quot;0&quot; /&gt;
&lt;input id=&quot;checkboxValue&quot; name=&quot;checkboxValue&quot; type=&quot;checkbox&quot; value=&quot;notCheckedValue&quot; /&gt; </pre>
<p>Pero debería generar el siguiente HTML</p>
<pre class="brush: xml;">
&lt;!-- Debería producir//--&gt;
&lt;input name=&quot;checkboxValue&quot; type=&quot;hidden&quot; value=&quot;notCheckedValue&quot; /&gt;
&lt;input id=&quot;checkboxValue&quot; name=&quot;checkboxValue&quot; type=&quot;checkbox&quot; value=&quot;checkedValue&quot; /&gt; </pre>
<p>Esto genera que los datos siempre se envíen vacíos, quiere decir si marcamos el <strong>checkbox</strong> este llegará vació, como si no lo hubiésemos marcado.</p>
<p><strong>Solución</strong><br />
Aun no existe un parche oficial para este problema, pero si queremos seguir trabajando podemos editar el <strong>helper</strong> del <strong>checkbox</strong> ubicado en  <strong>Zend/Dojo/View/Helper/CheckBox.php</strong> y agregar una pequeña línea de código para solucionarlo, hasta esperar que corrijan dicho problema.</p>
<p>Hay que agregar lo siguiente <strong> $checkedOptions = $attribs['options'];</strong> después de la línea <strong> 74</strong></p>
<pre class="brush: php;">
 public function checkBox($id, $value = null, array $params = array(), array $attribs = array(), array $checkedOptions = null)
    {
        // Prepare the checkbox options
        require_once 'Zend/View/Helper/FormCheckbox.php';
        $checked = false;
        if (isset($attribs['checked']) &amp;&amp; $attribs['checked']) {
            $checked = true;
        } elseif (isset($attribs['checked'])) {
            $checked = false;
        }
		//Linea Añadida &lt; -----
	    $checkedOptions = $attribs['options'];

        $checkboxInfo = Zend_View_Helper_FormCheckbox::determineCheckboxInfo($value, $checked, $checkedOptions);
        $attribs['checked'] = $checkboxInfo['checked'];
        if (!array_key_exists('id', $attribs)) {
            $attribs['id'] = $id;
        }

        $attribs = $this-&gt;_prepareDijit($attribs, $params, 'element');

        // strip options so they don't show up in markup
        if (array_key_exists('options', $attribs)) {
            unset($attribs['options']);
        }
//.............
</pre>
<p>El equipo de Zend ya esta haciendo un seguimiento a este problema y pronto tendremos la solución:</p>
<p>Aquí pueden ver la respuesta a mi pregunta sobre dicho error<br />
<a href="http://www.nabble.com/Error-Zend_Dojo-CheckBox-td19910115.html">http://www.nabble.com/Error-Zend_Dojo-CheckBox-td19910115.html</a></p>
<p><a href="http://www.nabble.com/Error-Zend_Dojo-CheckBox-td19910115.html">Issue Tracker<br />
</a><a href="http://framework.zend.com/issues/browse/ZF-4274">http://framework.zend.com/issues/browse/ZF-4274 </a></p>
]]></content:encoded>
			<wfw:commentRss>http://codigolinea.com/2008/10/10/error-en-el-elemento-checkbox-de-zend_dojo_form/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
