You are here

function video_embed_field_field_widget_form in Video Embed Field 7

Same name and namespace in other branches
  1. 7.2 video_embed_field.field.inc \video_embed_field_field_widget_form()

implementation of hook_field_widget_form

File

./video_embed_field.module, line 85

Code

function video_embed_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {

  //don't need to check the type right now because we're only defining one
  $element += array(
    '#type' => 'video_embed_field_widget',
  );
  $element['video_url'] = array(
    '#type' => 'textfield',
    '#title' => $element['#title'],
    '#description' => $element['#description'],
    '#attributes' => array(
      'class' => array(
        'video_embed_url',
      ),
    ),
    '#attached' => array(
      'css' => array(
        drupal_get_path('module', 'video_embed_field') . '/video_embed_field.form.css',
      ),
    ),
    '#default_value' => isset($items[$delta]['video_url']) ? $items[$delta]['video_url'] : '',
    '#required' => $element['#required'],
  );

  // Add the description field if enabled.
  if (!empty($instance['settings']['description_field'])) {
    $element['description'] = array(
      '#type' => 'textfield',
      '#title' => t('Description'),
      '#default_value' => isset($items[$delta]['description']) ? $items[$delta]['description'] : '',
      '#description' => t('The description which may be used as a label.'),
    );
  }
  return $element;
}