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.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jcisio’s picture

Status: Active » Needs review
FileSize
527 bytes
SylvainM’s picture

Status: Needs review » Reviewed & tested by the community

I tested this patch successfuly on different fields, thanks :)

  • anon committed 6fb53cb on 7.x-3.x authored by jcisio
    Fixed #2319721 by jcisio - Wrong element id when it is not the default...
anon’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the patch, this is now commited.

anon’s picture

Status: Fixed » Needs work

Sorry, 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.

jcisio’s picture

Status: Needs work » Needs review
FileSize
504 bytes

I'm not aware of any case of [value][#id] not defined so I can't test. But this patch should be safe.

anon’s picture

The 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.

  • text, single and multiple
  • text_long, single and multiple
  • link_field, single and multiple

None of them has ['value']['#id'] set.

jcisio’s picture

As 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).

anon’s picture

As 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.

anon’s picture

Status: Needs review » Fixed

Pushed the patch. Thanks.

  • anon committed 6ca588d on 7.x-3.x authored by jcisio
    Fixed #2319721 by jcisio - Wrong element id when it is not the default...

Status: Fixed » Closed (fixed)

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

The last submitted patch, 1: 2319721-linkit-element-id.patch, failed testing.

Status: Closed (fixed) » Needs work

The last submitted patch, 7: 2319721-linkit-element-id-7.patch, failed testing.

anon’s picture

Status: Needs work » Closed (fixed)

Closing again, the test bot change the status for some reason.