The role of field.module in D8 is supposed to be "support configurable fields".
The notions of field types, widgets, formatters, are shared with "base fields", and have already moved to Core/Field
Widgets, though, still rely on functions in field.form.inc :.
field_form_get_state() / field_form_set_state() / field_form_element_after_build() :
Handle clustering of $form_state to support forms with several nested entities.
The D8 shape of those is probably related to what happens with #1728816: Ensure multiple entity forms can be embedded into one form.
See also thoughts in #2095195-43: Remove deprecated field_attach_form_*().
field_add_more_submit() / field_add_more_js() :
Handle the "add more" button.
[edit: taken care of in #2201709: Move support for "add more" button into WidgetBase]
Those don't belong in field.module anymore, and should move out if we want to be able to make it a "non required" module #2199637: Replace "required" flag of Field module with proper dependencies
Comment | File | Size | Author |
---|---|---|---|
#16 | 2200355-remove_field.form_.inc-16.patch | 17.52 KB | yched |
#13 | interdiff.txt | 1.98 KB | yched |
#13 | 2200355-remove_field.form_.inc-13.patch | 17.52 KB | yched |
#10 | interdiff.txt | 979 bytes | yched |
#10 | 2200355-remove_field.form_.inc-10.patch | 17.5 KB | yched |
Comments
Comment #1
andypostPlace for
theme_field_multiple_value_form()
is interestingOthers could live in
WidgetBase
methodsComment #2
yched CreditAttribution: yched commentedre: theme_field_multiple_value_form() ;
On the display side, field.module's template_preprocess_field() / theme_field() / field.html.twig have the same flaw: they're now used for base fields and called from Core/Field, thus they all belong to system.module rather than field.module
Comment #3
sunSmall correction: System module is only a (needless) courier for registering the theme functions of the Drupal core base system.
Drupal core's base system theme functions live in
includes/theme.inc
and are defined bydrupal_common_theme()
.That's where the field theme functions should be moved into (unless we can get rid of them entirely, but let's leave that for a follow-up issue).
Comment #4
yched CreditAttribution: yched commented@sun : ok, so, if I get things right:
- field_theme() -> merged into drupal_common_theme() in theme.inc
- template_preprocess_field(), theme_field(), theme_field_multiple_value_form() -> theme.inc
- field.html.twig -> system/templates
- field_theme_suggestions_field() -> system.module
There's also field.module.css, that's added by field.module's hook_page_build(), would need to move into system_page_build() ?
That would be best in an issue of its own - I opened #2201693: Field output supporting code should move out of field.module.
Comment #5
yched CreditAttribution: yched commented+ patch for field_add_more_submit() / field_add_more_js() in #2201709: Move support for "add more" button into WidgetBase
Comment #6
yched CreditAttribution: yched commentedComment #7
yched CreditAttribution: yched commentedComment #8
yched CreditAttribution: yched commentedHere's a patch.
field.form.inc still contained :
- _field_sort_items_value_helper() : helper for usort
--> moved to includes/theme.inc, that's where it's used, in template_preprocess_field_multiple_value_form()
- field_form_element_after_build() : FAPI #after_build callback
--> moved to a static method in WidgetBase, like the rest of the supporting FAPI callables used by WidgetBase
- field_form_get_state() / field_form_set_state() + supporting _field_form_state_parents()
--> moved to static methods in WidgetBaseInterface / WidgetBase (static because we need them to be callable from various supporting FAPI #callbacks, that are better off static themselves)
And one less .inc file in field.module ! The last remaining one is field.purge.inc, that should be removed by #2282119: Make the Entity Field API handle field purging.
Comment #9
andypostAwesome! RTBC+1
Patch fixes minor nitpicks:
1) delete unneeded file
2)
looks like full namespace is needed here
Comment #10
yched CreditAttribution: yched commented1) Hm, dunno what happened when I rolled the patch, I did remove the field.form.inc file and the corresponding include locally, but it looks like it didn't make it to the patch I posted :-/.
Anyway - yeah, totally.
2) Yup, better indeed.
Additionnal doc fix - the current doc for field_form_get_state() was wrong, we don't place 'constraint_violations' in $form_state. We did at some point, but not anymore.
Comment #11
yched CreditAttribution: yched commentedSo, we need someone to RTBC this :-)
Comment #12
sunTwo quickies to get this to RTBC:
Shouldn't this refer to the template preprocess function?
Can we add a "get" prefix here?
Functions without get/set/... prefix are supposed to "do" something.
Comment #13
yched CreditAttribution: yched commented1) The current docs refer to the tpl, but sure, makes more sense I guess
2) Yup
Comment #14
sunThanks!
Comment #15
yched CreditAttribution: yched commentedCreated draft change records :
https://www.drupal.org/node/2294431
https://www.drupal.org/node/2294435
Comment #16
yched CreditAttribution: yched commentedStraight reroll after #2293723: Generate lighter $form[$field] structures.
Comment #17
alexpottCommitted 5f9c6c3 and pushed to 8.x. Thanks!
Comment #19
yched CreditAttribution: yched commentedThanks - I see you have published the change records.