class uo__unit_widget
Hierarchy
- class \TripalFieldWidget
- class \ChadoFieldWidget
- class \uo__unit_widget
- class \ChadoFieldWidget
Expanded class hierarchy of uo__unit_widget
1 string reference to 'uo__unit_widget'
- tripal_chado_bundle_instances_info_custom in tripal_chado/
includes/ tripal_chado.fields.inc - Helper function for the hook_create_tripalfield_instance().
File
- tripal_chado/
includes/ TripalFields/ uo__unit/ uo__unit_widget.inc, line 3
View source
class uo__unit_widget extends ChadoFieldWidget {
// The default lable for this field.
public static $default_label = 'Unit';
// The list of field types for which this formatter is appropriate.
public static $field_types = array('uo__unit');
/**
* @see TripalFieldWidget::form()
*/
public function form(&$widget, &$form, &$form_state, $langcode, $items, $delta, $element) {
parent::form($widget, $form, $form_state, $langcode, $items, $delta, $element);
$settings = $this->field['settings'];
$field_name = $this->field['field_name'];
$field_type = $this->field['type'];
$field_table = $this->instance['settings']['chado_table'];
$field_column = $this->instance['settings']['chado_column'];
$unittype_id = 0;
if (count($items) > 0 and array_key_exists('chado-' . $field_table . '__unittype_id', $items[0])) {
$unittype_id = $items[0]['chado-' . $field_table . '__unittype_id'];
}
$widget['value'] = array(
'#type' => 'value',
'#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '',
);
$cv = chado_get_cv(array('name' => 'featuremap_units'));
$options = chado_get_cvterm_select_options($cv->cv_id);
unset($options[0]);
$widget['chado-' . $field_table . '__unittype_id'] = array(
'#type' => 'select',
'#title' => $element['#title'],
'#description' => $element['#description'],
'#options' => $options,
'#default_value' => $unittype_id,
'#empty_option' => '- Select a Unit -',
'#required' => $element['#required'],
'#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
'#delta' => $delta,
);
}
/**
* @see TripalFieldWidget::validate()
*/
public function validate($element, $form, &$form_state, $langcode, $delta) {
$field_name = $this->field['field_name'];
$field_table = $this->instance['settings']['chado_table'];
// Make sure the value is set to the organism_id
$unittype_id = $form_state['values'][$field_name]['und'][0]['chado-' . $field_table . '__unittype_id'];
$form_state['values'][$field_name]['und'][0]['value'] = $unittype_id;
}
}
Members
Name | Modifiers | Type | Description |
---|---|---|---|
TripalFieldWidget:: |
public static | function | Provides information about the widgets provided by this field. |
TripalFieldWidget:: |
public | function | Performs extra commands when the entity form is submitted. |
TripalFieldWidget:: |
public | function | The theme function for the widget. |
TripalFieldWidget:: |
public | function | Instantiates a new TripalFieldWidget object. |
uo__unit_widget:: |
public static | property |
Overrides TripalFieldWidget:: |
uo__unit_widget:: |
public static | property |
Overrides TripalFieldWidget:: |
uo__unit_widget:: |
public | function |
Overrides TripalFieldWidget:: |
uo__unit_widget:: |
public | function |
Overrides TripalFieldWidget:: |