class data__sequence_widget
Hierarchy
- class \TripalFieldWidget
- class \ChadoFieldWidget
- class \data__sequence_widget
- class \ChadoFieldWidget
Expanded class hierarchy of data__sequence_widget
2 string references to 'data__sequence_widget'
- data__sequence.inc in tripal_chado/
includes/ TripalFields/ data__sequence/ data__sequence.inc - 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/ data__sequence/ data__sequence_widget.inc, line 3
View source
class data__sequence_widget extends ChadoFieldWidget {
// The default lable for this field.
public static $default_label = 'Sequence';
// The list of field types for which this formatter is appropriate.
public static $field_types = array('data__sequence');
/**
*
* @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'];
// Get the field defaults.
$residues = '';
if (count($items) > 0 and array_key_exists('value', $items[0])) {
$residues = $items[0]['value'];
}
if (array_key_exists('values', $form_state) and
array_key_exists($field_name, $form_state['values'])) {
$residues = $form_state['values'][$field_name][$langcode][$delta]['value'];
}
$widget['value'] = array(
'#type' => 'value',
'#value' => $residues,
);
$widget['chado-' . $field_table . '__' . $field_column] = array(
'#type' => 'textarea',
'#title' => $element['#title'],
'#description' => $element['#description'],
'#weight' => isset($element['#weight']) ? $element['#weight'] : 0,
'#default_value' => $residues,
'#delta' => $delta,
'#cols' => 30,
);
}
/**
*
* @see TripalFieldWidget::submit()
*/
public function validate($element, $form, &$form_state, $langcode, $delta) {
$field_name = $this->field['field_name'];
$field_table = $this->instance['settings']['chado_table'];
$field_column = $this->instance['settings']['chado_column'];
// Remove any white spaces.
$residues = $form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column];
if ($residues) {
$residues = preg_replace('/\s/', '', $residues);
$form_state['values'][$field_name]['und'][$delta]['value'] = $residues;
$form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column] = $residues;
}
// If the residue information has been removed then we want to signal such.
// When it's removed the value != residues but if it was never set then they're both empty.
elseif (!empty($form_state['values'][$field_name]['und'][$delta]['value'])) {
$form_state['values'][$field_name]['und'][$delta]['value'] = 'delete_me';
$form_state['values'][$field_name]['und'][$delta]['chado-' . $field_table . '__' . $field_column] = '';
}
}
}
Members
Name | Modifiers | Type | Description |
---|---|---|---|
data__sequence_widget:: |
public static | property |
Overrides TripalFieldWidget:: |
data__sequence_widget:: |
public static | property |
Overrides TripalFieldWidget:: |
data__sequence_widget:: |
public | function |
Overrides TripalFieldWidget:: |
data__sequence_widget:: |
public | function |
Overrides TripalFieldWidget:: |
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. |