コード例 #1
0
ファイル: list.php プロジェクト: atikahmed/joomla-probid
 /**
  * Method to get the field input markup for a generic list.
  * Use the multiple attribute to enable multiselect.
  *
  * @return  string  The field input markup.
  *
  * @since   11.1
  */
 protected function getInput()
 {
     // Initialize variables.
     $html = array();
     $attr = '';
     if (!self::$js_loaded) {
         RokCommon_Header::addInlineScript($this->attachJavaScript());
         self::$js_loaded = true;
     }
     // Initialize some field attributes.
     $attr .= $this->element['class'] ? ' class="' . (string) $this->element['class'] . '"' : '';
     // To avoid user's confusion, readonly="true" should imply disabled="true".
     if ((string) $this->element['readonly'] == 'true' || (string) $this->element['disabled'] == 'true') {
         $attr .= ' disabled="disabled"';
     }
     $attr .= $this->element['size'] ? ' size="' . (int) $this->element['size'] . '"' : '';
     $attr .= $this->multiple ? ' multiple="multiple"' : '';
     // Initialize JavaScript field attributes.
     $attr .= $this->element['onchange'] ? ' onchange="' . (string) $this->element['onchange'] . '"' : '';
     if ($this->element['attrs']) {
         $additional_attrs = explode(',', (string) $this->element['attrs']);
         foreach ($additional_attrs as $additional_attr) {
             $additional_attr = strtolower(trim($additional_attr));
             $attr .= $this->element[$additional_attr] ? sprintf(' %s="', $additional_attr) . (string) $this->element[$additional_attr] . '"' : '';
         }
     }
     // Get the field options.
     $options = (array) $this->getOptions();
     // Create a read-only list (no name) with a hidden input to store the value.
     if ((string) $this->element['readonly'] == 'true') {
         $html[] = JHtml::_('select.genericlist', $options, '', trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = '<input type="hidden" name="' . $this->name . '" value="' . $this->value . '"/>';
     } else {
         $list = JHtml::_('select.genericlist', $options, $this->name, trim($attr), 'value', 'text', $this->value, $this->id);
         $html[] = $list;
     }
     return implode($html);
 }