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']; $linker_field = 'chado-' . $field_table . '__protocol_id'; $protocols = []; //options are all protocols //It could be argued that options should only be protocols where protocol_type matches the bundle base table. $sql = "SELECT * FROM {protocol}"; $results = chado_query($sql); foreach ($results as $protocol) { $protocols[$protocol->protocol_id] = $protocol->name; } $widget['value'] = [ '#type' => 'select', '#title' => $element['#title'], '#description' => $element['#description'], '#options' => $protocols, '#empty_option' => '- Select a Protocol -', '#required' => $element['#required'], '#weight' => isset($element['#weight']) ? $element['#weight'] : 0, '#delta' => $delta, ]; } /** * Performs validation of the widgetForm. * * Use this validate to ensure that form values are entered correctly. * The 'value' key of this field must be set in the $form_state['values'] * array anytime data is entered by the user. It may be the case that there * are other fields for helping select a value. In the end those helper * fields must be used to set the 'value' field. */ public function validate($element, $form, &$form_state, $langcode, $delta) { } /** * Performs extra commands when the entity form is submitted. * * Drupal typically does not provide a submit hook for fields. The * TripalField provides one to allow for behind-the-scenes actions to * occur. This function should never be used for updates, deletes or * inserts for the Chado table associated with the field. Rather, the * storage backend should be allowed to handle inserts, updates deletes. * However, it is permissible to perform inserts, updates or deletions within * Chado using this function. Those operations can be performed if needed but * on other tables not directly associated with the field. * * An example is the chado.feature_synonym table. The chado_linker__synonym * field allows the user to provide a brand new synonynm and it must add it * to the chado.synonym table prior to the record in the * chado.feature_synonym table. This insert occurs in the widgetFormSubmit * function. * * @param $form * The submitted form array. * @param $form_state . * The form state array. * @param $entity_type * The type of $entity. * @param $entity * The entity for the operation. * @param $langcode * The language associated with $items. * @param $delta */ public function submit($form, &$form_state, $entity_type, $entity, $langcode, $delta) { } }