I have a content type with two relation select fields with unlimited instances.
The problem I'm facing is only with the first in the list: I add a second instance, enter a keyword, click on search. Instead of the launching the search, the main edit form is submitted.

Further information
I can confirm that the problem is due to the position of the relation select field. I changed the position of Relation A to be after Relation B. Now it's Relation B who has the problem.

Comments

manicato’s picture

Component: User interface » Code

The problem is that the ID of the submit button is not unique for the field.

My Situation:

Relation Field A
- Item 1 has #edit-submit--1 as ID
- Item 2 has #edit-submit--2 as ID

Relation Field B
- Item 1 has #edit-submit--3 as ID

Relation Field A: Now I add an item by clicking on "Add another item"
> Item 3 has #edit-submit--3 as ID which now is the same as the Item 1 of Relation Field B

The ID of the buttons generated should contain the name of the field.

Does anybody have an idea how to do this?

manicato’s picture

Status: Active » Needs review

OK, I found the solution myself:

$form['#after_build'] = array('relation_select_exposed_form_after_build');
$form['submit'] = array(
'#type' => 'submit',
'#value' => t('Search'),
+ '#id' => 'edit-submit-'.$element['#id'],
'#ajax' => array(
'path' => 'relation-select/ajax'
)
);

Can anyone please create a patch for this?

manicato’s picture

Here's the patch

manicato’s picture

Status: Needs review » Patch (to be ported)
chrisfromredfin’s picture

Hey there - just tested this patch on a relation select I have (only one relation field on this node type) that was set to unlimited. Patch solves problem in that case.

steveoliver’s picture

Status: Patch (to be ported) » Fixed

Thanks, manicato for the patch, and cwells for the testing. Committed to 7.x-1.x in 2195403.

Status: Fixed » Closed (fixed)

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

Anonymous’s picture

Issue summary: View changes

Further information