Varien_Data_Form_Element_Select Class Reference

Inheritance diagram for Varien_Data_Form_Element_Select:

Varien_Data_Form_Element_Abstract Varien_Data_Form_Abstract Varien_Object Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Boolean Mage_Adminhtml_Block_System_Config_Form_Field_Select_Allowspecific

List of all members.

Public Member Functions

 __construct ($attributes=array())
 getElementHtml ()
 getHtmlAttributes ()

Protected Member Functions

 _optionToHtml ($option, $selected)
 _prepareOptions ()


Detailed Description

Definition at line 34 of file Select.php.


Constructor & Destructor Documentation

__construct ( attributes = array()  ) 

Enter description here...

Parameters:
array $attributes

Reimplemented from Varien_Data_Form_Element_Abstract.

Reimplemented in Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Boolean.

Definition at line 36 of file Select.php.

00037     {
00038         parent::__construct($attributes);
00039         $this->setType('select');
00040         $this->setExtType('combobox');
00041         $this->_prepareOptions();
00042     }


Member Function Documentation

_optionToHtml ( option,
selected 
) [protected]

Definition at line 81 of file Select.php.

00082     {
00083         if (is_array($option['value'])) {
00084             $html ='<optgroup label="'.$option['label'].'">'."\n";
00085             foreach ($option['value'] as $groupItem) {
00086                 $html .= $this->_optionToHtml($groupItem, $selected);
00087             }
00088             $html .='</optgroup>'."\n";
00089         }
00090         else {
00091             $html = '<option value="'.$this->_escape($option['value']).'"';
00092             $html.= isset($option['title']) ? 'title="'.$option['title'].'"' : '';
00093             $html.= isset($option['style']) ? 'style="'.$option['style'].'"' : '';
00094             if (in_array($option['value'], $selected)) {
00095                 $html.= ' selected="selected"';
00096             }
00097             $html.= '>'.$option['label']. '</option>'."\n";
00098         }
00099         return $html;
00100     }

_prepareOptions (  )  [protected]

Definition at line 102 of file Select.php.

00103     {
00104         $values = $this->getValues();
00105         if (empty($values)) {
00106             $options = $this->getOptions();
00107             if (is_array($options)) {
00108                 $values = array();
00109                 foreach ($options as  $value => $label) {
00110                     $values[] = array('value' => $value, 'label' => $label);
00111                 }
00112             } elseif (is_string($options)) {
00113                 $values = array( array('value' => $options, 'label' => $options) );
00114             }
00115             $this->setValues($values);
00116         }
00117     }

getElementHtml (  ) 

Reimplemented from Varien_Data_Form_Element_Abstract.

Reimplemented in Mage_Adminhtml_Block_Catalog_Category_Helper_Sortby_Default.

Definition at line 44 of file Select.php.

00045     {
00046         $this->addClass('select');
00047         $html = '<select id="'.$this->getHtmlId().'" name="'.$this->getName().'" '.$this->serialize($this->getHtmlAttributes()).'>'."\n";
00048 
00049         $value = $this->getValue();
00050         if (!is_array($value)) {
00051             $value = array($value);
00052         }
00053 
00054         if ($values = $this->getValues()) {
00055             foreach ($values as $key => $option) {
00056                 if (!is_array($option)) {
00057                     $html.= $this->_optionToHtml(array(
00058                         'value' => $key,
00059                         'label' => $option),
00060                         $value
00061                     );
00062                 }
00063                 elseif (is_array($option['value'])) {
00064                     $html.='<optgroup label="'.$option['label'].'">'."\n";
00065                     foreach ($option['value'] as $groupItem) {
00066                         $html.= $this->_optionToHtml($groupItem, $value);
00067                     }
00068                     $html.='</optgroup>'."\n";
00069                 }
00070                 else {
00071                     $html.= $this->_optionToHtml($option, $value);
00072                 }
00073             }
00074         }
00075 
00076         $html.= '</select>'."\n";
00077         $html.= $this->getAfterElementHtml();
00078         return $html;
00079     }

getHtmlAttributes (  ) 

Reimplemented from Varien_Data_Form_Element_Abstract.

Definition at line 119 of file Select.php.

00120     {
00121         return array('title', 'class', 'style', 'onclick', 'onchange', 'disabled', 'readonly');
00122     }


The documentation for this class was generated from the following file:

Generated on Sat Jul 4 17:25:00 2009 for Magento by  doxygen 1.5.8