Public Member Functions | |
getOptions () | |
setOptions ($options) | |
addOption ($value, $label, $params=array()) | |
setId ($id) | |
setClass ($class) | |
setTitle ($title) | |
getId () | |
getClass () | |
getTitle () | |
getHtml () | |
Protected Member Functions | |
_toHtml () | |
_optionToHtml ($option, $selected=false) | |
Protected Attributes | |
$_options = array() |
Definition at line 35 of file Select.php.
_optionToHtml | ( | $ | option, | |
$ | selected = false | |||
) | [protected] |
Definition at line 148 of file Select.php.
00149 { 00150 $selectedHtml = $selected ? ' selected="selected"' : ''; 00151 $html = '<option value="'.$option['value'].'"'.$selectedHtml.'>'.$option['label'].'</option>'; 00152 00153 return $html; 00154 }
_toHtml | ( | ) | [protected] |
Override this method in descendants to produce html
Reimplemented from Mage_Core_Block_Abstract.
Definition at line 90 of file Select.php.
00091 { 00092 if (!$this->_beforeToHtml()) { 00093 return ''; 00094 } 00095 00096 $html = '<select name="'.$this->getName().'" id="'.$this->getId().'" class="' 00097 .$this->getClass().'" title="'.$this->getTitle().'" '.$this->getExtraParams().'>'; 00098 $values = $this->getValue(); 00099 00100 if (!is_array($values)){ 00101 if (!is_null($values)) { 00102 $values = array($values); 00103 } else { 00104 $values = array(); 00105 } 00106 } 00107 00108 $isArrayOption = true; 00109 foreach ($this->getOptions() as $key => $option) { 00110 if ($isArrayOption && is_array($option)) { 00111 $value = $option['value']; 00112 $label = $option['label']; 00113 } 00114 else { 00115 $value = $key; 00116 $label = $option; 00117 $isArrayOption = false; 00118 } 00119 00120 if (is_array($value)) { 00121 $html.= '<optgroup label="'.$label.'">'; 00122 foreach ($value as $keyGroup => $optionGroup) { 00123 if (!is_array($optionGroup)) { 00124 $optionGroup = array( 00125 'value' => $keyGroup, 00126 'label' => $optionGroup 00127 ); 00128 } 00129 $html.= $this->_optionToHtml( 00130 $optionGroup, 00131 in_array($optionGroup['value'], $values) 00132 ); 00133 } 00134 $html.= '</optgroup>'; 00135 } else { 00136 $html.= $this->_optionToHtml(array( 00137 'value' => $value, 00138 'label' => $label 00139 ), 00140 in_array($value, $values) 00141 ); 00142 } 00143 } 00144 $html.= '</select>'; 00145 return $html; 00146 }
addOption | ( | $ | value, | |
$ | label, | |||
$ | params = array() | |||
) |
Definition at line 51 of file Select.php.
00052 { 00053 $this->_options[] = array('value'=>$value, 'label'=>$label); 00054 return $this; 00055 }
getClass | ( | ) |
getHtml | ( | ) |
getId | ( | ) |
Retrieve object id
Reimplemented from Varien_Object.
Definition at line 75 of file Select.php.
00076 { 00077 return $this->getData('id'); 00078 }
getOptions | ( | ) |
getTitle | ( | ) |
setClass | ( | $ | class | ) |
Definition at line 63 of file Select.php.
00064 { 00065 $this->setData('class', $class); 00066 return $this; 00067 }
setId | ( | $ | value | ) |
Set object id field value
mixed | $value |
Reimplemented from Varien_Object.
Definition at line 57 of file Select.php.
00058 { 00059 $this->setData('id', $id); 00060 return $this; 00061 }
setOptions | ( | $ | options | ) |
setTitle | ( | $ | title | ) |
Definition at line 69 of file Select.php.
00070 { 00071 $this->setData('title', $title); 00072 return $this; 00073 }
$_options = array() [protected] |
Definition at line 38 of file Select.php.