Community

FAPI - clicked_button #ID returns wrong ID when button text is same

I have an ahah form which enables me to add groups and rows - Each new group has a 'Add New' button with ahah bindings. I set the #ID to addnew-1, addnew-2 etc...

I'm checking $form_state['clicked_button']['#id'] to determine which button is pressed, but the ID returned is always the ID of the newest button, regardless of the one clicked.

I have discovered that if I change the button text to 'Add New 1', 'Add New 2' etc.. then the correct ID is returned.

Has anyone else stumbled across this and found a workaround / fix for this?

Comments

My mistake

Discovered that #name must also be unique for each button - was defaulting to 'op'

See also:

nobody click here