You are here

function youtube_input_validate in YouTube Field 7

Validation for YouTube fields.

1 string reference to 'youtube_input_validate'
youtube_field_widget_form in ./youtube.module
Implements hook_field_widget_form().

File

./youtube.module, line 635

Code

function youtube_input_validate($element, &$form_state, $form) {
  $input = $element['#value'];
  $video_id = youtube_get_video_id($input);
  if ($video_id) {
    $video_id_element = array(
      '#parents' => $element['#parents'],
    );
    array_pop($video_id_element['#parents']);
    $video_id_element['#parents'][] = 'video_id';
    form_set_value($video_id_element, $video_id, $form_state);
  }
}