You are here

function synonyms_commerce_field_widget_settings_form in Synonyms 7

Implements hook_field_widget_settings_form().

File

synonyms_commerce/synonyms_commerce.module, line 57
Provides synonyms integration with Commerce.

Code

function synonyms_commerce_field_widget_settings_form($field, $instance) {
  $widget = $instance['widget'];
  $settings = $widget['settings'] + field_info_widget_settings($widget['type']);
  $form = array();
  switch ($widget['type']) {
    case 'synonyms_commerce_autocomplete':
      $form['suggestion_size'] = array(
        '#type' => 'textfield',
        '#title' => t('Suggestions Size'),
        '#description' => t('Please, enter how many suggested entities to show in the autocomplete textfield.'),
        '#required' => TRUE,
        '#element_validate' => array(
          'element_validate_integer_positive',
        ),
        '#default_value' => $settings['suggestion_size'],
      );
      $form['suggest_only_unique'] = array(
        '#type' => 'checkbox',
        '#title' => t('Suggest only one entry per product'),
        '#description' => t('If you want to include only product name or a single synonym, suggesting a particular product, while disregarding all ongoing ones, please, tick this checkbox on.'),
        '#default_value' => $settings['suggest_only_unique'],
      );
      break;
  }
  return $form;
}