field['field_name']; $field_type = $this->field['type']; // Get the setting for the option for how this widget. $instance = $this->instance; $settings = ''; $site_list = ''; $tokens = array(); // Get the form info from the bundle about to be saved. $bundle_info = tripal_load_bundle_entity(array('name' => $form_state['build_info']['args']['0']['bundle'])); // Retrieve all available tokens. $tokens = tripal_get_entity_tokens($bundle_info); // If the field already has a value then it will come through the $items // array. This happens when editing an existing record. // FORM PROPER $widget['#prefix'] = ""; $widget['#suffix'] = ""; $widget['value'] = array( '#type' => 'value', '#value' => array_key_exists($delta, $items) ? $items[$delta]['value'] : '', ); $widget['data_info'] = array( '#type' => 'fieldset', '#title' => 'Remote Data Settings', '#description' => 'Provide the site name, query and description for the remote data source.', '#collapsible' => TRUE, '#collapsed' => FALSE, '#prefix' => "
", '#suffix' => '
', ); // Get the site info from the tripal_sites table. // Get the field groups associated with this bundle. $sites = db_select('tripal_sites', 's') ->fields('s') ->execute()->fetchAll(); foreach ($sites as $site) { $rows[] = $site->name; } $widget['data_info']['site'] = array( '#type' => 'select', '#title' => t('Site'), '#options' => $rows, '#default_value' => $site_list, ); $widget['data_info']['query'] = array( '#type' => 'textarea', '#title' => 'Query', '#description' => 'Build the query string that should be appended after the url. The tokens listed below may be used in your query build.', '#default_value' => $this->instance['settings']['data_info']['query'], '#rows' => 5 ); $widget['set_titles']['token_display']['tokens'] = array( '#type' => 'hidden', '#value' => serialize($tokens) ); $widget['data_info']['token_display'] = array( '#type' => 'fieldset', '#title' => 'Available Tokens', '#description' => 'Copy the token and paste it into the "Query" text field above.', '#collapsible' => TRUE, '#collapsed' => TRUE ); $widget['data_info']['token_display']['content'] = array( '#type' => 'item', '#markup' => theme_token_list($tokens), ); $widget['data_info']['description'] = array( '#type' => 'textarea', '#title' => 'Description', '#description' => 'Describe the data being pulled in.', '#default_value' => $this->instance['settings']['data_info']['description'], '#rows' => 1 ); */ //TODO Add test button to ensure query returns info. } /** * 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) { //TODO validate the tokens, site, and query. Test that query returns data. } }