Hi, I have a form with 3 submit buttons, defined as
$form['submit1'] = array('#type' => 'submit',..) etc.

However, when I enter the form id to be ajaxified, nothing happens. What happens is that even with 1 button, if it's called ['submit1'], the form is not ajaxified.

I don't know if my case (3 submit buttons) is that wrong, but if I have a button with #type => submit, it shouldn't matter that it's called $form['something'] or?

Would be nice to have both cases fixed though :)

Thanks!
Martin

Comments

brendoncrawford’s picture

Assigned: Unassigned » brendoncrawford

Martin,

The problem is that even a preview or delete button will have '#type' => 'submit', so Ajax.module depends on the name being 'submit'. One possible workaround is that I allow a developer to set a form option to specify which button should be used as the submitter. Something like this:

$form['submit1'] = array(
  '#type' => 'submit',
  '#ajax_submitter' => TRUE,
  ...
);

Would something like that take care of your issue?

arski’s picture

Hi Brendon,

I suppose one could then set this setting to any button within a form, right? Would be really amazing!

Thanks in advance :)

Martin

brendoncrawford’s picture

Arski,

This has been fixed in 6.x-1.x-dev. The exact usage is as follows:

$form['submit1'] = array(
  '#type' => 'submit',
  '#ajax' => array(
    'submitter' => TRUE
  ),
  ...
);

Please allow up to 12 hours for the 6.x-1.x-dev package to update.

brendoncrawford’s picture

Status: Active » Fixed

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.