Exemplo n.º 1
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 public function render(Zikula_Form_View $view)
 {
     $html = '';
     $html .= "<script type=\"text/javascript\">\n<!--\n{$this->function} = function() { ";
     $html .= $view->getPostBackEventReference($this, $this->commandName);
     $html .= " }\n// -->\n</script>";
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $idHtml = $this->getIdHtml();
     $nameHtml = " name=\"{$this->inputName}[]\"";
     $readOnlyHtml = $this->readOnly ? " disabled=\"disabled\"" : '';
     $class = 'z-form-dropdownlist';
     if (!$this->isValid) {
         $class .= ' z-form-error';
     }
     if ($this->mandatorysym) {
         $class .= ' z-form-mandatory';
     }
     if ($this->readOnly) {
         $class .= ' z-form-readonly';
     }
     if ($this->cssClass != null) {
         $class .= ' ' . $this->cssClass;
     }
     $classHtml = $class == '' ? '' : " class=\"{$class}\"";
     $sizeHtml = $this->size == null ? '' : " size=\"{$this->size}\"";
     $postbackHtml = '';
     if ($this->autoPostBack) {
         $postbackHtml = " onchange=\"" . $view->getPostBackEventReference($this, '') . "\"";
     }
     $multipleHtml = '';
     if ($this->selectionMode == 'multiple') {
         $multipleHtml = " multiple=\"multiple\"";
     }
     $attributes = $this->renderAttributes($view);
     $result = "<select{$idHtml}{$nameHtml}{$readOnlyHtml}{$classHtml}{$postbackHtml}{$multipleHtml}{$sizeHtml}{$attributes}>\n";
     $currentOptGroup = null;
     foreach ($this->items as $item) {
         $optgroup = isset($item['optgroup']) ? $item['optgroup'] : null;
         if ($optgroup != $currentOptGroup) {
             if ($currentOptGroup != null) {
                 $result .= "</optgroup>\n";
             }
             if ($optgroup != null) {
                 $result .= "<optgroup label=\"" . DataUtil::formatForDisplay($optgroup) . "\">\n";
             }
             $currentOptGroup = $optgroup;
         }
         $text = DataUtil::formatForDisplay($item['text']);
         if ($item['value'] === null) {
             $value = '#null#';
         } else {
             $value = DataUtil::formatForDisplay($item['value']);
         }
         if ($this->selectionMode == 'single' && $value == $this->selectedValue) {
             $selected = ' selected="selected"';
         } else {
             if ($this->selectionMode == 'multiple' && in_array($value, (array) $this->selectedValue)) {
                 $selected = ' selected="selected"';
             } else {
                 $selected = '';
             }
         }
         $result .= "<option value=\"{$value}\"{$selected}>{$text}</option>\n";
     }
     if ($currentOptGroup != null) {
         $result .= "</optgroup>\n";
     }
     $result .= "</select>\n";
     if ($this->mandatorysym) {
         $result .= '<span class="z-form-mandatory-flag">*</span>';
     }
     return $result;
 }
Exemplo n.º 3
0
 /**
  * Render event handler.
  *
  * @param Zikula_Form_View $view Reference to Zikula_Form_View object.
  *
  * @return string The rendered output
  */
 function render(Zikula_Form_View $view)
 {
     $idHtml = $this->getIdHtml();
     $nameHtml = " name=\"{$this->groupName}\"";
     $readOnlyHtml = $this->readOnly ? " disabled=\"disabled\"" : '';
     $checkedHtml = $this->checked ? " checked=\"checked\"" : '';
     $postbackHtml = '';
     if ($this->autoPostBack) {
         $postbackHtml = " onclick=\"" . $view->getPostBackEventReference($this, '') . "\"";
     }
     $class = 'z-form-radio';
     if ($this->mandatory && $this->mandatorysym) {
         $class .= ' z-form-mandatory';
     }
     if ($this->readOnly) {
         $class .= ' z-form-readonly';
     }
     if ($this->cssClass != null) {
         $class .= ' ' . $this->cssClass;
     }
     $attributes = $this->renderAttributes($view);
     $result = "<input{$idHtml}{$nameHtml} type=\"radio\" value=\"{$this->value}\"{$readOnlyHtml}{$checkedHtml}{$postbackHtml}{$attributes} class=\"{$class}\" />";
     if ($this->mandatory && $this->mandatorysym) {
         $result .= '<span class="z-form-mandatory-flag">*</span>';
     }
     return $result;
 }