In media_formater_ahah_form, I'm trying to store the passed $uri, so we know what file we're using after submission of the formatter. However, I can't get the value to stick; it's the correct value when it gets to that step, as evidenced by dpm, but a later dpm shows NULL for the #value. I tried setting #type to 'textfield' and #value into #default_value, and it actually works there, inserting the URI into the text field and passing into the form values. But if I set the #type to #value or #hidden, and keep the value in #value, it doesn't pass to the form values.

Here's what I stuck in the current version of CVS (look at $form['uri']).

/**
 *  AHAH form displayed under the file selector.
 *
 *  @param array $form_state
 *  @param array $options
 *  @param array $forms
 *  @param string $uri
 *    The file that's just been selected or uploaded.
 *  @return array
 *    drupal form array
 */
function media_formater_ahah_form($form_state, $options, $forms, $uri) {
  $form['formatter'] = array(
    '#type' => 'fieldset',
    '#title' => t('Format options'),
  );

  // If we only have one option, display that.
  if (count($options) > 1) {
    $form['formatter']['formatter_select'] = array(
      '#type' => 'select',
      '#title' => t('Select the formater to use'),
      '#options' => $options,
    );
  }
  $form['formatter'][] = $forms;

  // @TODO: Why won't this value stick?
  // We need to pass this for final submission.
  $form['uri'] = array(
    '#type' => 'value',
    '#value' => $uri,
  );

  $form['formatter']['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Format'),
  );
  return $form;
}

function media_formater_ahah_form_submit($form, &$form_state) {
  if (function_exists('dpm')) {
    dpm($form);
    dpm($form_state);
  }
}

What am I doing wrong?

Comments

aaron’s picture

Status: Active » Fixed

This part is working now. Can't modify a value/hidden from an original form in AHAH, so created a new form now. We're refactoring anyway to use md5 so we don't even need the original file to do the metadata work.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.