You are here

function schemaorg_ui_form_field_ui_field_edit_form_alter in Schema.org 7

Implements hook_form_FORM_ID_alter().

File

modules/schemaorg_ui/schemaorg_ui.module, line 60
User interface for setting the schema.org mappings

Code

function schemaorg_ui_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
  $field_name = $form['#field']['field_name'];
  $bundle = $form['instance']['bundle']['#value'];
  $instance = $form['instance'];
  $label = isset($instance['label']) ? $instance['label']['#default_value'] : $instance['field_name'];
  $entity_type = $instance['entity_type']['#value'];
  $mapping = rdf_mapping_load($entity_type, $instance['bundle']['#value']);
  $form['schemaorg_ui'] = array(
    '#type' => 'fieldset',
    '#title' => t('%label schema.org mapping', array(
      '%label' => $label,
    )),
  );
  $form['schemaorg_ui']['schemaorg_ui_field_property'] = array(
    '#type' => 'textfield',
    '#title' => t('Property'),
    '#description' => t('Specify the property you want to associated to this field.'),
    '#default_value' => schemaorg_ui_term_load($entity_type, $bundle, $field_name),
    '#attributes' => array(
      'class' => array(
        'schemaorg-ui-autocomplete-properties',
      ),
    ),
  );
  $form['#submit'][] = 'schemaorg_ui_field_ui_field_edit_form_submit';

  // Use jQuery UI autocomplete to provide a faster autocomplete without
  // callback to the server.
  $form['#attached']['library'][] = array(
    'system',
    'ui.autocomplete',
  );
  $form['#attached']['css'][] = drupal_get_path('module', 'schemaorg_ui') . '/css/schemaorg_ui.jquery.ui.theme.css';
  $form['#attached']['js'][] = drupal_get_path('module', 'schemaorg_ui') . '/js/schemaorg_ui.js';
  $form['#attached']['js'][] = array(
    'data' => array(
      'schemaorguiapiTermsPath' => base_path() . drupal_get_path('module', 'schemaorg_ui') . '/js/schemaorg_ui.terms.json',
    ),
    'type' => 'setting',
  );
}