Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 PST on 31 March 2024, to get $100 off your ticket.
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.
Comment | File | Size | Author |
---|---|---|---|
#1 | link-1980736-1.patch | 444 bytes | star-szr |
#1 | link-1980736-before.png | 21.58 KB | star-szr |
#1 | link-1980736-after.png | 24.06 KB | star-szr |
Comments
Comment #1
star-szrThis 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
After
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.
Comment #2
star-szrComment #3
jcfiala CreditAttribution: jcfiala commentedOkay, that seems pretty harmless and easy to add. Fixed in dev branch. Thanks!
Comment #4
star-szrGreat, thanks!
Comment #6
star-szrI was going to update a patched version but actually I'm not seeing this commit anywhere. @jcfiala can you take a look please?
Comment #7
jcfiala CreditAttribution: jcfiala commentedI'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.)
Comment #8
star-szrThanks.