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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | Relation_select-support_multiple_fields_in_form-1860892-1.patch | 518 bytes | manicato |
Comments
Comment #1
manicato commentedThe 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?
Comment #2
manicato commentedOK, 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?
Comment #3
manicato commentedHere's the patch
Comment #4
manicato commentedComment #5
chrisfromredfinHey 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.
Comment #6
steveoliver commentedThanks, manicato for the patch, and cwells for the testing. Committed to 7.x-1.x in 2195403.
Comment #7.0
(not verified) commentedFurther information