The element value ID is not always the element ID suffixed by "-value". In fact it can be forced, e.g. in hook_field_widget_form_alter() with something like this:
$element['#id'] = drupal_html_id('edit-' . $context['field']['field_name']);
But LinkIt makes the following assumption:
$field_id = $element['#id'] . '-value';
I'll upload a patch.
| Comment | File | Size | Author |
|---|---|---|---|
| #7 | 2319721-linkit-element-id-7.patch | 504 bytes | jcisio |
| #1 | 2319721-linkit-element-id.patch | 527 bytes | jcisio |
Comments
Comment #1
jcisio commentedComment #2
sylvainm commentedI tested this patch successfuly on different fields, thanks :)
Comment #4
anonThanks for the patch, this is now commited.
Comment #5
anonSorry, I should have tested this more.
I have reverted the commit again.
The patch assumes that all elements has an
[value][#id], and that is not the case.Comment #7
jcisio commentedI'm not aware of any case of [value][#id] not defined so I can't test. But this patch should be safe.
Comment #8
anonThe patch seems to solves the problem, but I cant see the reason for the patch.
What type of fields are we talking about here?
I made some research and as it turns out, none of my tested fields have
['value']['#id']set.I have tested the three field types that link supports.
None of them has
['value']['#id']set.Comment #9
jcisio commentedAs I said in the summary, an element can be forced to use an id different than the default value using hook_field_widget_form_alter (introduced in Drupal 7.8).
Comment #10
anonAs I remembered it, #id was only use for internal usage, but I became unsecue and did some research.
It turns out, #id is "kind of" internal. You can specify your own one, but that is uncommon.
Source: https://api.drupal.org/api/drupal/developer!topics!forms_api_reference.h...
Now I have legit reasons for adding your latest patch, thanks.
Comment #11
anonPushed the patch. Thanks.
Comment #16
anonClosing again, the test bot change the status for some reason.