Actually all buttons in a Drupal form have the name "op" so that you can easily determine which button was pressed in the submit function. i.e. if ($op = 'blah) or switch ($op).

If you are using the Drupal Ahah framework for this then your submit function should handle it. But since all your buttons are titled Remove, what you can do is use $form_state['clicked_button']['#id'] to determine which button was clicked in your submit function. As #id is built of the array key you give the element in the $form variable.

-----
Adam A. Gregory
Drupal Developer & Consultant
Web: AdamAGregory.com
Twitter: twitter.com/adamgregory
Phone: 910.808.1717
Cell: 919.306.6138


On Wed, Jun 23, 2010 at 11:15 AM, Ken Winters <kwinters@coalmarch.com> wrote:
Does it have to be a giant form? Using anchor tags and then a confirm form is fairly common.

Objects in a form do need to have unique names / IDs.

- Ken Winters


On Jun 23, 2010, at 10:36 AM, Richard Morse wrote:

Hi! I'm trying to build an AHAH form which allows users to add and remove steps.

I'm building a table like:

Id       Note
----------------------------------------------
1       [This is a step       ]      <remove>
2       [This is another step ]      <remove>
3       [Make me an offer!    ]      <remove>

<add step>

In order to be able to determine which remove button was pressed, I'm creating them like:

 array(
  '#type'  => 'button',
  '#name'  => 'remove_btn_' . $row_id,
  '#value' => 'remove',
  '#ahah'  => ...
 )

I'm doing this because otherwise the form state shows the clicked_button always as the last of the remove buttons created.

According to the forms_api_reference on api.drupal.org, in the section for '#name',

All button and submit elements on a form should have the same name

Am I breaking something by setting the name for each button separately? If so, how am I supposed to distinguish between the various remove buttons?

Thanks,
Ricky


The information in this e-mail is intended only for the person to whom it is
addressed. If you believe this e-mail was sent to you in error and the e-mail
contains patient information, please contact the Partners Compliance HelpLine at
http://www.partners.org/complianceline . If the e-mail was sent to you in error
but does not contain patient information, please contact the sender and properly
dispose of the e-mail.