theme_link_field() calls drupal_render() for all the render elements defined in link_field_process(), but does not allow other modules to add to the widget output.

This came up while testing the Field Remove Item module, which implements hook_field_widget_form_alter() and adds a new element to the widget.

Patch coming.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

star-szr’s picture

Status: Active » Needs review
FileSize
24.06 KB
21.58 KB
444 bytes

This way you're limited to appending elements, but it's progress.

Tested http://drupal.org/project/field_remove_item before and after applying the patch:

Before
link-1980736-before.png

After
link-1980736-after.png

Longer term (I can create a separate issue for the refactor) it might make more sense to create the whole widget including wrapping divs as a render array in link_field_process() and then just render everything in the theme function. If the whole thing is a render array then you can play with the weight of individual form elements as well, right now the order of the fields is fixed because it's just concatenating strings. Of course you can override theme_link_field(), but if you're using Seven as your admin theme you don't really want to start hacking Seven to move fields around.

star-szr’s picture

Assigned: Unassigned » star-szr
jcfiala’s picture

Issue summary: View changes
Status: Needs review » Fixed

Okay, that seems pretty harmless and easy to add. Fixed in dev branch. Thanks!

star-szr’s picture

Assigned: star-szr » Unassigned

Great, thanks!

Status: Fixed » Closed (fixed)

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

star-szr’s picture

Status: Closed (fixed) » Needs review

I was going to update a patched version but actually I'm not seeing this commit anywhere. @jcfiala can you take a look please?

jcfiala’s picture

Status: Needs review » Fixed

I'm sorry - You're right, that somehow got lost.

I've re-added it. It'll show up in 7.x-1.x-dev soon. (And I double-checked at https://drupal.org/node/74971/commits to make sure the commit went through.)

star-szr’s picture

Thanks.

Status: Fixed » Closed (fixed)

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