You are here

function feeds_form_alter in Feeds 6

Same name and namespace in other branches
  1. 7 feeds.module \feeds_form_alter()

Implements hook_form_alter().

Related topics

File

./feeds.module, line 472
Feeds - basic API functions and hook implementations.

Code

function feeds_form_alter(&$form, $form_state, $form_id) {
  if (isset($form['#node']->type) && $form['#node']->type . '_node_form' == $form_id) {
    if ($importer_id = feeds_get_importer_id($form['#node']->type)) {

      // Set title to not required, try to retrieve it from feed.
      if (isset($form['title'])) {
        $form['title']['#required'] = FALSE;
      }

      // Enable uploads.
      $form['#attributes']['enctype'] = 'multipart/form-data';

      // Build form.
      $source = feeds_source($importer_id, empty($form['#node']->nid) ? 0 : $form['#node']->nid);
      $form['feeds'] = array(
        '#type' => 'fieldset',
        '#title' => t('Feed'),
        '#tree' => TRUE,
        '#weight' => 0,
      );
      $form['feeds'] += $source
        ->configForm($form_state);
      $form['#feed_id'] = $importer_id;
    }
  }
}