[development] Changing button #name?

Richard Morse remorse at partners.org
Wed Jun 23 14:36:47 UTC 2010


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.



More information about the development mailing list