[support] multiple buttons with same #value D5
Metzler, David
metzlerd at evergreen.edu
Wed Mar 25 19:57:12 UTC 2009
Yeah I understood that, but what I was pointing out is that you can get
all your id's field data grouped by $id in your forms array if you
reversed the nesting and put them in a container. You'd still need to
use the name trick to get the buttons detected right ( I Think) .
Sorry if I wasn't clear. Here's a fictional example from a shopping
cart metafor.
The form --
// Build the rows of items.
While (....) {
$row['qty] = array('#type' => 'textfield' ...);
$row['size'] = array('#type' => 'radios');
$items[$id] = $row;
}
$form['items'] = $items;
$form['items']['#tree'] = TRUE;
The values
// Iterate the cart
foreach ($form_values['items'] as $id=>$item) {
// inside this loop $item['qty'] is the quantity
// and $item['size'] is the size
}
I just thought you (and others) might find this useful.
Dave
-----Original Message-----
From: support-bounces at drupal.org [mailto:support-bounces at drupal.org] On
Behalf Of Ivan Sergio Borgonovo
Sent: Wednesday, March 25, 2009 12:35 PM
To: support at drupal.org
Subject: Re: [support] multiple buttons with same #value D5
On Wed, 25 Mar 2009 12:29:09 -0700
"Metzler, David" <metzlerd at evergreen.edu> wrote:
> A little known fact... You can create containers in the forms array
> that have no visual representation in the form, kind of like
> fieldsets, but without the fieldset.
>
> While (...) {
> $form[$id] = array('#tree' => TRUE);
> $form[$id]['qty'] = array(....);
> $form[$id]['add'] = array(....);
> }
>
> Might clean up some of the code you've discovered.
>
> I usually nest all the rows into a single fieldset as well, but
> that's optional.
No they were actual editable values.
Each row had a textfield (qty) and a button + a "superbutton" at the end
of the table.
Anyway problem was solved directly controlling the name attribute.
--
Ivan Sergio Borgonovo
http://www.webthatworks.it
--
[ Drupal support list | http://lists.drupal.org/ ]
More information about the support
mailing list