Varien_Data_Form_Element_Checkboxes Class Reference

Inheritance diagram for Varien_Data_Form_Element_Checkboxes:

Varien_Data_Form_Element_Abstract Varien_Data_Form_Abstract Varien_Object

List of all members.

Public Member Functions

 __construct ($attributes=array())
 getHtmlAttributes ()
 getElementHtml ()
 getChecked ($value)
 getDisabled ($value)
 getOnclick ($value)
 getOnchange ($value)

Protected Member Functions

 _prepareValues ()
 _optionToHtml ($option)


Detailed Description

Definition at line 34 of file Checkboxes.php.


Constructor & Destructor Documentation

__construct ( attributes = array()  ) 

Init Element

Parameters:
array $attributes

Reimplemented from Varien_Data_Form_Element_Abstract.

Definition at line 41 of file Checkboxes.php.

00042     {
00043         parent::__construct($attributes);
00044         $this->setType('checkbox');
00045         $this->setExtType('checkbox');
00046     }


Member Function Documentation

_optionToHtml ( option  )  [protected]

Definition at line 189 of file Checkboxes.php.

00190     {
00191         $id = $this->getHtmlId().'_'.$this->_escape($option['value']);
00192 
00193         $html = '<li><input id="'.$id.'"';
00194         foreach ($this->getHtmlAttributes() as $attribute) {
00195             if ($value = $this->getDataUsingMethod($attribute, $option['value'])) {
00196                 $html .= ' '.$attribute.'="'.$value.'"';
00197             }
00198         }
00199         $html .= ' value="'.$option['value'].'" />'
00200             . ' <label for="'.$id.'">' . $option['label'] . '</label></li>'
00201             . "\n";
00202         return $html;
00203     }

_prepareValues (  )  [protected]

Prepare value list

Returns:
array

Definition at line 63 of file Checkboxes.php.

00063                                         {
00064         $options = array();
00065         $values  = array();
00066 
00067         if ($this->getValues()) {
00068             if (!is_array($this->getValues())) {
00069                 $options = array($this->getValues());
00070             }
00071             else {
00072                 $options = $this->getValues();
00073             }
00074         }
00075         elseif ($this->getOptions() && is_array($this->getOptions())) {
00076             $options = $this->getOptions();
00077         }
00078 
00079         foreach ($options as $k => $v) {
00080             if (is_string($v)) {
00081                 $values[] = array(
00082                     'label' => $v,
00083                     'value' => $k
00084                 );
00085             }
00086             elseif (isset($v['value'])) {
00087                 if (!isset($v['label'])) {
00088                     $v['label'] = $v['value'];
00089                 }
00090                 $values[] = array(
00091                     'label' => $v['label'],
00092                     'value' => $v['value']
00093                 );
00094             }
00095         }
00096 
00097         return $values;
00098     }

getChecked ( value  ) 

Definition at line 123 of file Checkboxes.php.

00124     {
00125         if ($checked = $this->getValue()) {
00126         }
00127         elseif ($checked = $this->getData('checked')) {
00128         }
00129         else {
00130             return ;
00131         }
00132         if (!is_array($checked)) {
00133             $checked = array(strval($checked));
00134         }
00135         else {
00136             foreach ($checked as $k => $v) {
00137                 $checked[$k] = strval($v);
00138             }
00139         }
00140 
00141         if (array_search(strval($value), $checked)) {
00142             return 'checked';
00143         }
00144         return ;
00145     }

getDisabled ( value  ) 

Definition at line 147 of file Checkboxes.php.

00148     {
00149         if ($disabled = $this->getData('disabled')) {
00150             if (!is_array($disabled)) {
00151                 $disabled = array(strval($disabled));
00152             }
00153             else {
00154                 foreach ($disabled as $k => $v) {
00155                     $disabled[$k] = strval($v);
00156                 }
00157             }
00158             if (array_search(strval($value), $disabled)) {
00159                 return 'disabled';
00160             }
00161         }
00162         return ;
00163     }

getElementHtml (  ) 

Retrieve HTML

Returns:
string

Reimplemented from Varien_Data_Form_Element_Abstract.

Definition at line 105 of file Checkboxes.php.

00106     {
00107         $values = $this->_prepareValues();
00108 
00109         if (!$values) {
00110             return '';
00111         }
00112 
00113         $html  = '<ul class="checkboxes">';
00114         foreach ($values as $value) {
00115             $html.= $this->_optionToHtml($value);
00116         }
00117         $html .= '</ul>'
00118             . $this->getAfterElementHtml();
00119 
00120         return $html;
00121     }

getHtmlAttributes (  ) 

Retrieve allow attributes

Returns:
array

Reimplemented from Varien_Data_Form_Element_Abstract.

Definition at line 53 of file Checkboxes.php.

00054     {
00055         return array('type', 'name', 'class', 'style', 'checked', 'onclick', 'onchange', 'disabled');
00056     }

getOnchange ( value  ) 

Definition at line 173 of file Checkboxes.php.

00174     {
00175         if ($onchange = $this->getData('onchange')) {
00176             return str_replace('$value', $value, $onchange);
00177         }
00178         return ;
00179     }

getOnclick ( value  ) 

Definition at line 165 of file Checkboxes.php.

00166     {
00167         if ($onclick = $this->getData('onclick')) {
00168             return str_replace('$value', $value, $onclick);
00169         }
00170         return ;
00171     }


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

Generated on Sat Jul 4 17:24:59 2009 for Magento by  doxygen 1.5.8