Esempio n. 1
0
 /**
  * dijit.form.CheckBox
  *
  * @param  int $id
  * @param  string $content
  * @param  array $params  Parameters to use for dijit creation
  * @param  array $attribs HTML attributes
  * @param  array $checkedOptions Should contain either two items, or the keys checkedValue and uncheckedValue
  * @return string
  */
 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']) && $attribs['checked']) {
         $checked = true;
     } elseif (isset($attribs['checked'])) {
         $checked = false;
     }
     $checkboxInfo = Zend_View_Helper_FormCheckbox::determineCheckboxInfo($value, $checked, $checkedOptions);
     $attribs['checked'] = $checkboxInfo['checked'];
     if (!array_key_exists('id', $attribs)) {
         $attribs['id'] = $id;
     }
     $attribs = $this->_prepareDijit($attribs, $params, 'element');
     // strip options so they don't show up in markup
     if (array_key_exists('options', $attribs)) {
         unset($attribs['options']);
     }
     // and now we create it:
     $html = '';
     if (!strstr($id, '[]')) {
         // hidden element for unchecked value
         $html .= $this->_renderHiddenElement($id, $checkboxInfo['uncheckedValue']);
     }
     // and final element
     $html .= $this->_createFormElement($id, $checkboxInfo['checkedValue'], $params, $attribs);
     return $html;
 }
Esempio n. 2
0
 /**
  * dijit.form.CheckBox
  * 
  * @param  int $id 
  * @param  string $content 
  * @param  array $params  Parameters to use for dijit creation
  * @param  array $attribs HTML attributes
  * @return string
  */
 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']) && $attribs['checked']) {
         $checked = true;
     } elseif (isset($attribs['checked'])) {
         $checked = false;
     }
     $checkboxInfo = Zend_View_Helper_FormCheckbox::determineCheckboxInfo($value, $checked, $checkedOptions);
     $attribs['checked'] = $checkboxInfo['checked'];
     $attribs = $this->_prepareDijit($attribs, $params, 'element');
     // and now we create it:
     $html = '';
     if (!strstr($id, '[]')) {
         // hidden element for unchecked value
         $html .= '<input name="' . $id . '" type="hidden" value="' . $this->view->escape($checkboxInfo['unCheckedValue']) . '"' . $this->getClosingBracket();
     }
     // and final element
     $html .= $this->_createFormElement($id, $value, $params, $attribs);
     return $html;
 }