Mage_Core_Block_Html_Select Class Reference

Inheritance diagram for Mage_Core_Block_Html_Select:

Mage_Core_Block_Abstract Varien_Object Mage_Adminhtml_Block_Html_Select

List of all members.

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()


Detailed Description

Definition at line 35 of file Select.php.


Member Function Documentation

_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

Returns:
string

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 (  ) 

Definition at line 80 of file Select.php.

00081     {
00082         return $this->getData('class');
00083     }

getHtml (  ) 

Definition at line 156 of file Select.php.

00157     {
00158         return $this->toHtml();
00159     }

getId (  ) 

Retrieve object id

Returns:
mixed

Reimplemented from Varien_Object.

Definition at line 75 of file Select.php.

00076     {
00077         return $this->getData('id');
00078     }

getOptions (  ) 

Definition at line 40 of file Select.php.

00041     {
00042         return $this->_options;
00043     }

getTitle (  ) 

Definition at line 85 of file Select.php.

00086     {
00087         return $this->getData('title');
00088     }

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

Parameters:
mixed $value
Returns:
Varien_Object

Reimplemented from Varien_Object.

Definition at line 57 of file Select.php.

00058     {
00059         $this->setData('id', $id);
00060         return $this;
00061     }

setOptions ( options  ) 

Definition at line 45 of file Select.php.

00046     {
00047         $this->_options = $options;
00048         return $this;
00049     }

setTitle ( title  ) 

Definition at line 69 of file Select.php.

00070     {
00071         $this->setData('title', $title);
00072         return $this;
00073     }


Member Data Documentation

$_options = array() [protected]

Definition at line 38 of file Select.php.


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

Generated on Sat Jul 4 17:23:53 2009 for Magento by  doxygen 1.5.8