'', 'chado_column' => '', 'base_table' => '', 'semantic_web' => '', ); // Set this to the name of the storage backend that by default will support // this field. public static $default_storage = 'field_chado_storage'; /** * @see TripalField::formatterView() */ public function formatterView(&$element, $entity_type, $entity, $langcode, $items, $display) { foreach ($items as $delta => $item) { $content = key_exists('value', $item) ? $item['value'] : ''; $element[$delta] = array( // We create a render array to produce the desired markup, '#type' => 'markup', '#markup' => $content, ); } } /** * @see TripalField::widgetForm() */ public function widgetForm(&$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->field['settings']['chado_table']; $field_column = $this->field['settings']['chado_column']; // Get the field defaults. $md5checksum = ''; if (count($items) > 0 and array_key_exists('feature__md5checksum', $items[0])) { $md5checksum = $items[0]['feature__md5checksum']; } if (array_key_exists('values', $form_state)) { //$md5checksum = tripal_chado_get_field_form_values($field_name, $form_state, 0, 'feature__md5checksum'); } $widget['value'] = array( '#type' => 'value', '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '', ); $widget['feature__md5checksum'] = array( '#type' => 'value', '#value' => $md5checksum, // '#element_validate' => array('chado_feature__md5checksum_widget_validate'), ); } public function widgetFormSubmit($entity_type, $entity, $langcode, &$items, $form, &$form_state) { $field = $this->field; $settings = $field['settings']; $field_name = $field['field_name']; $field_type = $field['type']; $field_table = $field['settings']['chado_table']; $field_column = $field['settings']['chado_column']; // Calculate the md5 checksum for the sequence only if md5 box is checked and // the residues exist. //$residues = tripal_chado_get_field_form_values('feature__residues', $form_state, 0, 'feature__residues'); if ($residues) { $residues = preg_replace('/\s/', '', $residues); tripal_chado_set_field_form_values($field_name, $form_state, md5($residues), 0, 'feature__md5checksum'); } else { // Otherwise, remove the md5 value tripal_chado_set_field_form_values($field_name, $form_state, '__NULL__', 0, $field_table . '__md5checksum'); } } }