public function UCXF_Field::generate in Extra Fields Checkout Pane 7
Same name and namespace in other branches
- 6.2 class/UCXF_Field.class.php \UCXF_Field::generate()
generate() Generates a field array used in forms generated by uc_extra_fields_pane @access public
Return value
void
File
- class/
UCXF_Field.class.php, line 642 - Contains the UCXF_Field class.
Class
- UCXF_Field
- Base class for a Extra Fields Pane field
Code
public function generate() {
$return_field = array();
switch ($this->value_type) {
case self::UCXF_WIDGET_TYPE_TEXTFIELD:
$return_field = array(
'#type' => 'textfield',
'#title' => $this
->output('label'),
'#description' => $this
->output('description'),
'#size' => 32,
'#maxlength' => 255,
'#required' => $this->required,
);
// Add default value only when there is one
$default_value = $this
->generate_value();
if ($default_value != '') {
$return_field['#default_value'] = $default_value;
}
break;
case self::UCXF_WIDGET_TYPE_CHECKBOX:
$return_field = array(
'#type' => 'checkbox',
'#title' => $this
->output('label'),
'#description' => $this
->output('description'),
'#required' => $this->required,
);
break;
case self::UCXF_WIDGET_TYPE_SELECT:
$return_field = array(
'#type' => 'select',
'#title' => $this
->output('label'),
'#description' => $this
->output('description'),
'#required' => $this->required,
'#options' => $this
->generate_value(),
);
break;
case self::UCXF_WIDGET_TYPE_PHP:
case self::UCXF_WIDGET_TYPE_CONSTANT:
$return_field = array(
'#type' => 'hidden',
'#value' => $this
->generate_value(),
);
break;
case self::UCXF_WIDGET_TYPE_PHP_SELECT:
$return_field = array(
'#type' => 'select',
'#title' => $this
->output('label'),
'#description' => $this
->output('description'),
'#required' => $this->required,
'#options' => $this
->generate_value(),
);
break;
}
return $return_field;
}