Updated: Comment #0
Problem/Motivation
After #2144327: Make all field types provide a schema() all field types could be used for entity displays if they have any widget|formatter.
Currently if field type has "configurable = TRUE" in annotation that means that field type gets the \Drupal\Core\Field\ConfigFieldItemList as default list class.
But actually that means that field items have default value widget (ConfigFieldItemListInterface) and settings form for field and instance (ConfigFieldItemInterface), but this forms cannot be accessed if we have "no_ui" in annotation.
The "no_ui" annotation is used to disallow fields to be added via field_ui module to entities, that means that this kind fields could be added in code only.
Last usage of the method should be removed in #2198917: Use the string field type for the node title field
Proposed resolution
Remove "configurable" annotation and rely on interfaces in field_ui form builders.
Replace the getConfigurableDefinitions() method with getUiDefinitions() from interface as it makes not sense anymore.
Remaining tasks
make patch,
get approvement about api clean-up
make change notice or update existing?
update https://drupal.org/node/2064123
And the review others in #2218199-9: Move email and number field types to \Drupal\Core\Field, remove modules
User interface changes
no
API changes
Removal of FieldTypePluginManagerInterface::getConfigurableDefinitions() and "configurable" setting from annotation
| Comment | File | Size | Author |
|---|---|---|---|
| #48 | field-types.png | 40.69 KB | swentel |
| #48 | interdiff.txt | 1.84 KB | swentel |
| #48 | field_configurable_followup-2191709-2.patch | 2.42 KB | swentel |
| #46 | field_configurable_followup-2191709.patch | 598 bytes | yched |
| #41 | 2191709-field-configurable-41.patch | 23.28 KB | andypost |
Comments
Comment #1
andypostPatch includes hunk from #2191555: Allow DisplayOverviewBase use all field types
Comment #2
andypostTrying to remove "configurable" annotation in favor of "no_ui"
The only questionable part is
FieldTypePluginManager::processDefinition()that marked by@todoSuppose
list_classshould be assigned a different way, for example "class implements interface" but maybe better to re-think this automatic class assign at all, at this stage I'm not really sure about reasons for thisComment #5
andypostFix last usage of "configurable" and test.
Add more robust check for field instance edit form
Comment #7
andypost5: 2191709-field-configurable-4.patch queued for re-testing.
Unrelated failure in
\Drupal\views_ui\Tests\DisplayTestComment #8
andypostThe issue needs feedback and should be commited after #2191555: Allow DisplayOverviewBase use all field types or we could combine them in one
Comment #9
berdirIf we do this, then we have to kill the Configurable*Interface interfaces and classes too and merge whatever they do up into their parent. Otherwise you could create a non-configurable field without no_ui and it would blow up.
Comment #10
andypostThere's only:
ConfigFieldItemInterface- declares settings form for field and instance, going to fixConfigFieldItemListInterface- just declares default value forms, already fixed in patchComment #11
andypostFix to not "blow up" field ui.
Entity edit & view is not affected.
Let's see what bot say
Comment #12
amateescu commentedI had a patch for this sitting on my desktop for quite a while so I opened an issue for it: #2192259: Remove ConfigField.. Item and List classes + interfaces
Comment #13
berdirIt's not unused, so let's remove that from the title.
Comment #14
andypostre-roll
Comment #15
yched commentedSo, I know there was a discussion on whether 'no_ui' and 'configurable' were redundant, but I can't really remember the arguments why both were kept :-/
Other than that, I do feel a little nervous about removing 'configurable' before we have removed the separation between "field type that can be used for configurable fields" and "field types that can only be used for base fields". Can't really point a specific reason atm, so this might just be FUD...
How is this code (or the 'no_ui' flag) related to the notion of "default value" ?
Why is this needed ?
Same, why ?
Unfinished sentence
Comment #16
yched commentedQuoting Berdir on IRC:
a) We still needed a way to have configurable fields that can only be added in code, that's what no_ui is for.
b) back when we made base fields use the @FieldType annotation and introduced configurable, base fields weren't ready to be used as configurable fields (no schema() etc). but amateescu's issue to drop the ConfigField* classes and interfaces it going to remove the final blocker there
So right, doing this is fine, but I still vaguely feel it would be best to do things in order here and wait for #2192259: Remove ConfigField.. Item and List classes + interfaces , but I'll defer to @amateescu.
Comment #17
berdirYes, waiting for that does make sense, agreed. Long dependency chain, but I think that's preferable in this case.
Comment #18
andypostI think better to make this one first because it really shows the purpose of 'configurable' definition - to provide default value widget!
#15
1) The ConfigFieldItemListInterface now only tells that field support default value widget|validate|submit. So "no_ui" means that we can't add dield and can't configure field|instance settings via Field UI.
2 and 3) when manager can't instantiate the widget or formatter plugin because there's no plugins (including default_widget|formatter) they should return nothing.
4) paraphrased: no interface means there's no default value widget (that what 'configurable' was for)
PS: in follow up we can find a better approach about how to check presence of default value widget
Comment #19
andypostclarified this in summary
Comment #20
amateescu commentedI agree with @yched and @Berdir, it doesn't really make sense to remove 'configurable' until we remove the classes in #2192259: Remove ConfigField.. Item and List classes + interfaces. Also, hook_field_info() in D7 defined default_formatter and default_widget as non-optional, and I think we should stick with that (e.g. throw an exception if a field type doesn't declare them).
Comment #21
andypost#2192259: Remove ConfigField.. Item and List classes + interfaces is in, so now we have
isConfigurable()method, that could be used to check that field is configurable byreturn !empty($definition['no_ui']) && empty($definition['default_widget']) && empty($definition['default_formatter'])Comment #22
berdirWhat I was wondering is if we should add a method on the field type manager to encapsulate *that* ? Or alternatively throw an exception for an field that does not have no_ui set but is missing a default widget or formatter?
I don't think we should make it required to have a widget and formatter for fields that can not be added in the UI, various core field types are not meant to be edited in the UI, for example the UUID (if anything, you could display it, but not edit and a read-only widget doesn't make much sense?).
Comment #23
andypostRe-roll with #21
EDITdiscussed at IRCComment #25
andypostThe things left to decide:
1) add field to entity - suppose 'no_ui' should stay for that purpose
2) allow to use field in manage form - field should have default_widget at least, but some contrib module could add widget that is not set for that field as default...
3) same for formatters - at least default_formatter is needed, otoh formatter manager could be extended with
getAvailableFormatters()to make sure that field can be used in "manage display" (entityViewDisplay)4) default values - to allow "configure" base and attached fields we need a listing of all fields (field_ui /fields route) and allow field_ui route for "edit field" to allow change label and default value
PS: suppose 4) this is a feature and could be done later or contrib
Comment #26
berdir1) Yep.
2) & 3) Yes, as mentioned above, I think we should keep a function to return field types that don't have no_ui set and a default widget and formatter.
4.) That would be cool but definitely a different issue.
What we are actually doing here is remove the "configurable" flag on field types, I think that's what the issue title should be saying. We'll keep a method on the field type manager (that's my suggestion anyway), just named differently. I'm not sure what.. getUiDefinitions() getDefinitionsWithUi() getAddableDefinitions() ? No idea...
Comment #27
andypostFiled #2218219: _editor_get_processed_text_fields() should search text_processing only in text fields
Comment #28
andypostTrying to remove
isConfigurable()methodComment #29
berdirHm, you should be able to drop all this, because $definition *is* already the instance, and should therefore have the correct label.
I'd expect this check to go away in https://drupal.org/node/2095195, if not already, then it probably should.
Comment #31
andypostFix merge error and use renamed function in
hook_help()Comment #33
andypost#31 is a broken bot
new patch should fix left failures caused by entity cache, that should be fixed by #597236: Add entity caching to core
the only place to use
getUiDefinitions()infield_help()now, that could be replaced with inline filteringComment #34
andypostComment #35
berdirNeeds a re-roll due to email/number but looks great.
... that can be added... I think.
EmailItem has been merged, so no longer no_ui :)
Same.
$definition === $instance already, so you can remove this part completely.
This was only necessar due to the entity cache change, it should no longer be needed. I'd suggest to remove it to avoid conflicts with the entity cache patch.
Comment #36
andypostFixed 1-4, for #4 just added check for interface because solving @todo is out of scope the issue
About #5 (patch also contains a hunk from #2218219: _editor_get_processed_text_fields() should search text_processing only in text fields)
This still needed, because with a patch entities are cached with all fields.
Comment #37
berdirNo they are not, they were at one point but we changed that back because it caused a bunch of other test fails. Try it, it should pass just fine without that change.
Agree on the @todo in content_translation, didn't see all of it, that's something for #2143291: Clarify handling of field translatability.
This looks ready to me, but a review from one of the field API maintainers would be nice.
Comment #38
andypostSo removed the hunk in text tests
Comment #39
andypostLet's see how many failures could be if we remove #15 (2-3) hunk
Also re-roll patch after #2181549: Provide a StringLong field item with schema type 'text' without a 'format' column.
Comment #40
andypostSeems something was fixed in core so "no-null" is passed!
@yched any more left?
Comment #41
andypostRe-roll after #2120871: Rename EntityListController to EntityListBuilder
Comment #42
swentel commentedWorks for me.
Comment #43
webchickI asked Berdir for some more information on this, since I wasn't totally grokking the purpose of this patch from the issue summary.
Basically, back when we had both "base" fields and "configurable" fields, this distinction made sense. But over time, we've settled on all fields deriving from the same "base" type. Now, "not-configurable" doesn't make sense as a separate distinction, because if all you want to do is prevent a field from being configured in the UI, you can use the existing no_ui property for that.
Therefore...
Committed and pushed to 8.x. Thanks!
Comment #45
andypostUpdated change notices:
https://drupal.org/node/2064123
https://drupal.org/node/2111927
Comment #46
yched commentedThe second one looks like a mistake ?
Comment #47
andypostSure, merge typo
Comment #48
swentel commentedWe actually forgot a couple more
Comment #49
andypostDrop is moving
Comment #50
webchickCommitted and pushed that to 8.x, too.
Comment #52
andypostFix title