Source for file combo.php

Documentation is available at combo.php

  1. <?php
  2. /**
  3.  * @package     Joomla.Platform
  4.  * @subpackage  Form
  5.  *
  6.  * @copyright   Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
  7.  * @license     GNU General Public License version 2 or later; see LICENSE
  8.  */
  9.  
  10. defined('JPATH_PLATFORM') or die;
  11.  
  12.  
  13. /**
  14.  * Form Field class for the Joomla Platform.
  15.  * Implements a combo box field.
  16.  *
  17.  * @package     Joomla.Platform
  18.  * @subpackage  Form
  19.  * @since       11.1
  20.  */
  21. {
  22.     /**
  23.      * The form field type.
  24.      *
  25.      * @var    string 
  26.      * @since  11.1
  27.      */
  28.     protected $type = 'Combo';
  29.  
  30.     /**
  31.      * Method to get the field input markup for a combo box field.
  32.      *
  33.      * @return  string  The field input markup.
  34.      *
  35.      * @since   11.1
  36.      */
  37.     protected function getInput()
  38.     {
  39.         $html = array();
  40.         $attr = '';
  41.  
  42.         // Initialize some field attributes.
  43.         $attr .= !empty($this->class) ? ' class=combobox"' . $this->class . '"' : ' class="combobox"';
  44.         $attr .= $this->readonly ? ' readonly' : '';
  45.         $attr .= $this->disabled ? ' disabled' : '';
  46.         $attr .= !empty($this->size) ? ' size="' . $this->size . '"' : '';
  47.         $attr .= $this->required ? ' required aria-required="true"' : '';
  48.  
  49.         // Initialize JavaScript field attributes.
  50.         $attr .= $this->onchange ? ' onchange="' . $this->onchange . '"' : '';
  51.  
  52.         // Get the field options.
  53.         $options = $this->getOptions();
  54.  
  55.         // Load the combobox behavior.
  56.         JHtml::_('behavior.combobox');
  57.  
  58.         $html[] = '<div class="combobox input-append">';
  59.  
  60.         // Build the input for the combo box.
  61.         $html[] = '<input type="text" name="' . $this->name . '" id="' . $this->id . '" value="'
  62.             . htmlspecialchars($this->value, ENT_COMPAT, 'UTF-8') . '"' . $attr . ' autocomplete="off" />';
  63.  
  64.         $html[] = '<div class="btn-group">';
  65.         $html[] = '<button type="button" class="btn dropdown-toggle">';
  66.         $html[] = '        <span class="caret"></span>';
  67.         $html[] = '</button>';
  68.  
  69.         // Build the list for the combo box.
  70.         $html[] = '<ul class="dropdown-menu">';
  71.  
  72.         foreach ($options as $option)
  73.         {
  74.             $html[] = '<li><a href="#">' . $option->text . '</a></li>';
  75.         }
  76.  
  77.         $html[] = '</ul>';
  78.  
  79.         $html[] = '</div></div>';
  80.  
  81.         return implode($html);
  82.     }
  83. }

Documentation generated on Tue, 19 Nov 2013 14:56:05 +0100 by phpDocumentor 1.4.3