Closed (duplicate)
Project:
Drupal core
Version:
8.0.x-dev
Component:
node system
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Issue tags:
Reporter:
Created:
6 Nov 2011 at 01:05 UTC
Updated:
29 Jul 2014 at 20:07 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #1
chx commentedExample:
and so on for every field type callback.
Comment #2
chx commentedAnd, change $function = $instance['widget']['module'] . '_field_widget_form'; to $function = $instance['widget']['widget callback']; in field_default_form
Comment #3
chx commentedFind me on IRC if it doesnt feel so novice :)
Other such hooks are http://api.drupal.org/api/drupal/modules--field--field.api.php/group/fie... load, validate, submit, presave, insert, update, delete, delete_revision, is_empty, schema, prepare_view, prepare_translation, (these callback definitions all go into hook_field_info) then formatter_prepare_view, formatter_view (these go into hook_field_formatter_info) and then widget_form, widget_error (these go into hook_field_widget_info).
Comment #4
catchHow is this different to #702586: hook_field_load() and friends are not real hooks?
Comment #5
pat redmond commentedI've run through and changed all the files which contain "_field_widget_info()". Getting some errors from simpletest -> not really sure why or where to fix. I figure it is a good idea to fix these before running through the other 'hooks'.
Comment #6
decipheredTabbing is incorrect, need to use two spaces instead of tabs.
Comment #7
swentel commentedYeah, this is pretty much duplicate of the one that catch mentions in #4. I vote duplicate, but let's at least get one more opinion about it.
Comment #8
pat redmond commentedOK, this has me stumped. For some reason it isn't displaying the widgets correctly... I originally thought that it was an issue with the text.test, but I don't think that is the case. For some reason the 'widget callback' doesn't seem to be registering.
The other weird thing is that when I change (in text.module)
to
it doesn't seem to make any difference - I var_dump($instance) and 'rows' remains at 20...
Comment #10
Anonymous (not verified) commentedSince there hasn't been activity for 4+ weeks, I'm going to move this back to unassigned.
Comment #11
cedarm commentedWorking on this at DrupalCon sprint..
Comment #12
cedarm commentedAs for 'widget callback' not "registering", the instance needs it to be populated, just like 'module', in _field_info_prepare_instance_widget(). The newly defined callbacks in various hook_field_widget_info() were not all correct. Checked list, number, options, text, file, image, taxonomy, and test/field_test.
Comment #13
cedarm commentedOops, let's try that again.
Comment #15
cedarm commentedLooks like we also need to set $instance['widget']['widget callback'] in _field_write_instance(). Is this right?
Still need to handle _field_widget_error.
Comment #17
cedarm commentedDo we just need to check if isset 'widget callback' ?
Comment #19
cedarm commentedMissed one isset check.
Comment #21
cedarm commented_field_write_instance() doesn't care about 'widget callback'; rather 'widget callback' was missing from test_field_widget (I had only added it to test_field_widget_multiple).
Comment #22
cedarm commentedChanged 'widget callback' to 'widget form' and added 'widget error'. Is this the right direction?
Comment #24
cedarm commentedOk, forgot to put 'widget error' into _field_info_prepare_instance_widget(), but I don't think this is right. Why should the instance even need this information? Let's call field_info_widget_types() and get the callbacks from there instead of the instance.
Comment #25
joachim commented> Changed 'widget callback' to 'widget form' and added 'widget error'. Is this the right direction?
I would say not. There is a tendency in core (and contrib too) to name properties in an info array that are callbacks 'foo bar callback', eg in hook_menu(). That helps make it clear what it is.
Comment #26
cedarm commentedSo 'widget form callback' and 'widget error callback' then? And for load, validate, submit, presave, insert, update, ..., should these be 'load callback', 'validate callback', etc? Or should it be 'field load callback', 'field validate callback', etc?
Naming convention aside, is it correct to be getting these from the field info instead of the instance?
Comment #27
amateescu commentedI'm not sure that we should waste more energy on this. Field API is going the OO route anyway and will be rewritten when plugins land in D8. #1497366-5: Introduce Plugin System to Core
Comment #28
cedarm commentedThat's just what yched said in #702586-9: hook_field_load() and friends are not real hooks, but plugins and OO sound more certain now. If that's the direction for sure let's close this as a duplicate. Unassigning for now.
I am still willing to work on this, even if it's only a stepping stone to determine all of the spots to change for fields. I learned a lot anyway :)
Comment #29
swentel commentedEverything are now plugins, much nicer :)