Beispiel #1
0
 /**
  * {@inheritdoc}
  */
 public function optionsForm(&$form, &$form_state)
 {
     $geocoder_handlers = array();
     foreach (geocoder_handler_info() as $name => $handler) {
         $geocoder_handlers[$name] = $handler['title'];
     }
     $form['options']['geocoder_handler'] = array('#type' => 'select', '#title' => t('Geocoder handler'), '#options' => $geocoder_handlers, '#required' => TRUE, '#default_value' => $this->getOption('geocoder_handler', 'google'));
     $form['options']['geocoder_cache'] = array('#type' => 'select', '#title' => t('Geocoder cache type'), '#description' => t('Type of geocoder cache to use'), '#options' => array(0 => t('No caching'), 1 => t('Static-cache but no persistent-cache'), 2 => t('Both static-cache and persistent-cache')), '#default_value' => $this->getOption('geocoder_cache', 0));
     $fields = $this->getOption('fields', array(array()));
     if (!empty($fields[0])) {
         $fields[] = array();
     }
     foreach ($fields as $index => $field) {
         $form['options']['fields'][$index] = array('#type' => 'fieldset', '#title' => $field == end($fields) ? t('Add a new feature') : 'Feature ' . $index, '#collapsible' => TRUE, '#collapsed' => $field == end($fields) ? TRUE : FALSE, 'title' => array('#title' => 'Title', '#type' => 'textfield', '#default_value' => isset($fields[$index]['title']) ? $fields[$index]['title'] : ''), 'description' => array('#title' => 'Description', '#type' => 'textarea', '#default_value' => isset($fields[$index]['description']) ? $fields[$index]['description'] : ''), 'address' => array('#title' => 'Address', '#type' => 'textfield', '#default_value' => isset($fields[$index]['address']) ? $fields[$index]['address'] : ''), 'wkt' => array('#type' => 'textfield', '#title' => 'WKT', '#disabled' => TRUE, '#default_value' => isset($fields[$index]['wkt']) ? $fields[$index]['wkt'] : ''));
     }
 }
/**
 * Example for a location_input plugin form callback.
 *
 * @param array $form_state
 *   The form state data.
 * @param array $options
 *   The options for this plugin, as entered into this form previously.
 *
 * @return array
 *   A form array for configuring this location_input plugin. Upon submitting of
 *   the configuration form, the resulting $form_state['values'] will
 *   automatically be saved as the $options of this plugin for future
 *   invocations.
 */
function example_search_api_location_form_callback(array &$form_state, array $options)
{
    $handlers = array();
    foreach (geocoder_handler_info() as $id => $handler) {
        $handlers[$id] = $handler['title'];
    }
    $form['handler'] = array('#title' => t('Handler'), '#type' => 'select', '#options' => $handlers, '#default_value' => isset($options['handler']) ? $options['handler'] : NULL);
    return $form;
}