Closed (fixed)
Project:
MySite
Version:
4.7.x-3.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Reporter:
Created:
27 Nov 2006 at 16:21 UTC
Updated:
1 Jan 2007 at 16:45 UTC
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?
| Comment | File | Size | Author |
|---|---|---|---|
| multiforms.png | 65.54 KB | agentrickard |
Comments
Comment #1
agentrickardIt also turns out that this error causes the Rename feature to work incorrectly.
I will have a fix for that next week.
Comment #2
agentrickardThis has been patched and will be deployed later today.
Comment #3
(not verified) commented