I have an issue in writing a multipart form on a single page.

The user is presented a themed table, for which each Title element is editable. I place the edit forms on each row as follows:

    $rows = array();
    while ($entry = db_fetch_array($result)) {
      $form[$entry['mid']]['mysite_title']['title'] = array(
        '#type' => 'textfield',
        '#size' => '15',
        '#default_value' => NULL
      );
      $form[$entry['mid']]['mysite_title']['mid'] = array(
        '#type' => 'hidden',
        '#value' => $entry['mid']
      );        
      $form[$entry['mid']]['mysite_title']['uid'] = array(
        '#type' => 'hidden',
        '#value' => $entry['uid']
      );        
      $form[$entry['mid']]['mysite_title']['submit'] = array(
        '#type' => 'submit',
        '#value' => t('Rename')
      );          
      $remove = mysite_remove_link($owner->uid, $entry['mid']);
      $promote = mysite_promote_link($owner->uid, $entry['mid']);
      $demote = mysite_demote_link($owner->uid, $entry['mid']);        
      $rows[] = array('data' => array(check_plain($entry['title']), theme('mysite_actions', $entry['uid'], $entry['mid']), drupal_get_form('mysite_edit_title', $form[$entry['mid']])));        
    }

On submit, the form is run through the validate hook:

    $sql = "SELECT mid FROM {mysite_data} WHERE lower(title) = '%s' AND uid = %s";
    $check = db_fetch_object(db_query($sql, trim(strtolower($form_values['title'])), $form_values['uid']));
    if ($check->mid > 0) {
      form_set_error('title', t('The title must be unique.')); 
    }

The problem is that the error is reported for all instances of 'title' on the form. (See attached.)

How can I write this form so that proper error reporting can be handled?

CommentFileSizeAuthor
multiforms.png65.54 KBagentrickard

Comments

agentrickard’s picture

Component: User interface » Code
Category: support » bug

It also turns out that this error causes the Rename feature to work incorrectly.

I will have a fix for that next week.

agentrickard’s picture

Version: 4.7.x-3.0 » 4.7.x-3.x-dev
Status: Active » Fixed

This has been patched and will be deployed later today.

Anonymous’s picture

Status: Fixed » Closed (fixed)