You are here

function video_params_form_alter in Video 5

Same name and namespace in other branches
  1. 6 plugins/video_params/video_params.module \video_params_form_alter()
  2. 6.2 plugins/video_params/video_params.module \video_params_form_alter()

Implementation of hook_form_alter() We use this to add a text area to the video creation form. In the text area the user will be able to insert his param value association.

File

plugins/video_params/video_params.module, line 38
Enable addition of params to object generated by video module

Code

function video_params_form_alter($form_id, &$form) {
  if ($form_id == 'video_node_form' && isset($form['video']) && user_access('insert object params')) {

    // get node object
    $node = $form['#node'];

    //We must convert the array data back to something that can go in the textarea.
    $textarea = '';
    if (is_array($node->serial_data['object_parameters'])) {
      foreach ($node->serial_data['object_parameters'] as $param => $value) {
        $textarea .= $param . '=' . $value . "\n";
      }
      $textarea = substr($textarea, 0, -1);

      //Remove the last newline "\n" from the end.
    }
    $form['parameters'] = array(
      '#type' => 'fieldset',
      '#title' => t('HTML object parameters'),
      '#collapsible' => TRUE,
      '#collapsed' => TRUE,
      '#weight' => -17,
    );
    $form['parameters']['object_parameters'] = array(
      '#title' => t('Embedded object parameters'),
      '#type' => 'textarea',
      '#rows' => 5,
      '#default_value' => $textarea,
      '#description' => t('Enter the values that you would like to be embedded in <param name="param_1" value="value_1" /> tags. Each parameter should be on a seperate line with an equal sign between the parameter and its assigned value. Like param=value for example.'),
    );
  }
}