You are here

function video_settings_form_validate in Video 6.2

Same name and namespace in other branches
  1. 5 video.module \video_settings_form_validate()
  2. 6 video.module \video_settings_form_validate()

Form API callback to validate the upload settings form.

Keeps the use from showing the play tab or the play link if they have chosen to display the video in the node body.

Parameters

$form_id: The identifier of the form

$form_values: form values from the settings page

File

./video.module, line 443
video.module

Code

function video_settings_form_validate($form, &$form_state) {

  //print_r($form_state['values']); die;
  if ($form_state['values']['video_flowplayer_module']) {
    if (!module_exists('flowplayer')) {
      form_set_error("video_flowplayer_module", t('You have not installed flowplayer module. <a href="@link">Download and install flowplayer module.</a>', array(
        '@link' => url('http://drupal.org/project/flowplayer'),
      )));
    }
  }

  // if admin set a name for a resolution he also have to set its value
  while ($i <= 4) {
    if ($form_state['values']["video_resolution_{$i}_name"] != '' && $form_state['values']["video_resolution_{$i}_value"] == '') {
      form_set_error("video_resolution_{$i}_value", t('You have to set a value for resolution %res_num if you want to enable it.', array(
        '%res_num' => $i,
      )));
    }
    if ($form_state['values']["video_resolution_{$i}_value"] != '' && !preg_match('/^[0-9]{2,4}x[0-9]{2,4}$/', $form_state['values']["video_resolution_{$i}_value"])) {

      // check valid resolution value
      form_set_error("video_resolution_{$i}_value", t('You have to set valid value for resolution %res_num if you want to enable it. A valid value is 400x300', array(
        '%res_num' => $i,
      )));
    }
    $i++;
  }

  // for future use
}