public function testSetIdFromAttribs()
 {
     $helper = new Zend_View_Helper_FormCheckbox();
     $element = $helper->formCheckbox('foo', null, array('id' => 'bar'));
     $this->assertContains('name="foo"', $element);
     $this->assertContains('id="bar"', $element);
 }
 public function formCheckbox($name, $value = null, $attribs = null, array $checkedOptions = null)
 {
     $inputLabel = isset($attribs['input_label']) ? $attribs['input_label'] : null;
     if (is_array($attribs)) {
         unset($attribs['input_label']);
     }
     $xhtml = parent::formCheckbox($name, $value, $attribs, $checkedOptions);
     if (!isset($attribs['escape']) || $attribs['escape']) {
         $inputLabel = $this->view->escape($inputLabel);
     }
     // Wraps the checkbox with its own label (not the decorator one),
     // if the attrib input_label is added
     if ($inputLabel) {
         $xhtml = '<label class="checkbox"' . ' for="' . $this->view->escape($name) . '">' . $xhtml . $inputLabel . '</label>';
     }
     return $xhtml;
 }
 /**
  * Generates a 'text' element.
  *
  * @access public
  *
  * @param string|array $name If a string, the element name.  If an
  * array, all other parameters are ignored, and the array elements
  * are used in place of added parameters.
  *
  * @param mixed $value The element value.
  *
  * @param array $attribs Attributes for the element tag.
  *
  * @return string The element XHTML.
  */
 public function formTextOverwrite($name, $value = null, $attribs = null)
 {
     $info = $this->_getInfo($name, $value, $attribs);
     extract($info);
     // name, value, attribs, options, listsep, disabled
     $viewHelperFormCheckbox = new Zend_View_Helper_FormCheckbox();
     $viewHelperFormCheckbox->setView($this->view);
     $viewHelperFormElement = new Zend_View_Helper_FormText();
     $viewHelperFormElement->setView($this->view);
     $checked = '';
     if ($attribs['overwrite']) {
         $checked = 'checked';
         $disabled = true;
         unset($attribs['overwrite']);
     } else {
         $disabled = false;
         if (isset($attribs['class']) && $attribs['class'] != '') {
             $attribs['class'] = $attribs['class'] . ' disabled';
         } else {
             $attribs['class'] = 'disabled';
         }
     }
     $separator = '';
     if (isset($attribs['separator'])) {
         $separator = $attribs['separator'];
         unset($attribs['separator']);
     }
     $xhtml = '<div class="input-prepend">';
     $xhtml .= '<label class="add-on">';
     $xhtml .= $viewHelperFormCheckbox->formCheckbox($name . '[overwrite]', null, array_merge($attribs, array('checked' => $checked, 'class' => 'checkbox text-overwrite-checkbox')));
     $xhtml .= '</label>';
     $xhtml .= ' ' . $separator;
     if (!$disabled) {
         $xhtml .= $viewHelperFormElement->formText($name . '[value]', $value, array_merge($attribs, array('disabled' => 'disabled')));
     } else {
         $xhtml .= $viewHelperFormElement->formText($name . '[value]', $value, $attribs);
     }
     $xhtml .= '</div>';
     return $xhtml;
 }
示例#4
0
 public function formCheckbox($name, $value = null, $attribs = null, array $checkedOptions = array(1, 0))
 {
     return parent::formCheckbox($name, $value, $attribs, $checkedOptions);
 }