You are here

function video_embed_field_field_widget_form in Video Embed Field 7.2

Same name and namespace in other branches
  1. 7 video_embed_field.module \video_embed_field_field_widget_form()

Implements hook_field_widget_form().

File

./video_embed_field.field.inc, line 153
Implement a video field.

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' => 'fieldset',
  );
  $element['video_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Video URL'),
    '#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'],
    '#maxlength' => 255,
  );

  // 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.'),
      '#maxlength' => $instance['settings']['description_length'],
    );
  }
  return $element;
}