In #1230534: allowed_views should be an instance setting, not a field setting (Viewfield) and other issues on d.o, there's lots of uncertainty around this part of the current hook_field_info() docs:

  • settings: An array whose keys are the names of the settings available for the field type, and whose values are the default values for those settings.
  • instance_settings: An array whose keys are the names of the settings available for instances of the field type, and whose values are the default values for those settings. Instance-level settings can have different values on each field instance, and thus allow greater flexibility than field-level settings. It is recommended to put settings at the instance level whenever possible. Notable exceptions: settings acting on the schema definition, or settings that Views needs to use across field instances (for example, the list of allowed values).

It is entirely not clear when it is valid to use instance settings (such as "allowed values", which can vary depending on field type).

Furthermore, according to the current docs, Drupal core seems to contain and provide invalid examples. Most field type modules in core only have field settings (and no instance settings), whereas most of the field settings do not affect the field schema, so according to and strictly following these docs, they should be instance settings.

So what? Clarification please.

Comments

sun’s picture

Issue tags: +Needs backport to D7
andypost’s picture

+1 It's really not clear what settings could be used on instance level and what limits for settings on field level

catch’s picture

I regularly get confused by this.

lars toomre’s picture

Thank you for raising this issue @sun. Like you, I am confused by these two settings arrays.

jhodgdon’s picture

Issue tags: -Documentation

subscribing. I really wish that doc-only issues would just get filed in the Documentation component. And FYI as far as I know, in Drupal Core no one monitors the 'documentation' tag... There are tag guidelines (see link below the tags field, and sub-pages that actually list the tags to use and not use), and this is clearly stated there. Thanks!

rafamd’s picture

I'll follow so as to learn more on this.

EDIT: deleted potentialy confusing content, as it used incorrect concept of "instance".

rafamd’s picture

EDIT: deleted potentialy confusing content, as it used incorrect concept of "instance".

sun’s picture

Before this issue gets out of control...

Looks like no one really knows about any other non-obvious implications (also not concerning Views or whatever), so we should heavily shorten and clarify the documentation to state:

  • settings: Any field-level setting that has an impact on the field's storage schema, or which has to be consistent across all field instances for custom field type module specific reasons. For anything else, use 'instance_settings'.
  • instance_settings: [Remove the mumbo-jumbo about Views, allowed values, and whatnot causing confusion.]
dave reid’s picture

Yep. 'settings' should only affect the field schema. Anything else should be 'instance_settings'.

dawehner’s picture

From my understanding this shouldn't break views in any place: the views-data doesn't rely on any field/instance settings
and the rendering part is using just plain fieldapi functions.
Fhe formatter settings are setup in views directly but this is not part of the issue.

andypost’s picture

views are rely on formatter settings which is other thing, but I think views are using field setting to know about the storage of the fields

jhodgdon’s picture

Component: field system » documentation
Issue tags: -Needs documentation

Thanks for all the discussion! So it looks like we need a patch based on comment #8. Moving to docs component now since it's a purely docs issue.

la2texas’s picture

Version: 8.x-dev » 7.x-dev

This may be the wrong place for this, but where ... on Gods green earth, can I find WHAT the "settings" array should include?!?!

If this is confusing for veterans, imagine my frustration just starting out.

clemens.tolboom’s picture

Version: 7.x-dev » 8.x-dev

[Powered by #1115636: Issue Macros and Templates]

Please do not change the core version. Please read http://drupal.org/node/767608 for the reasons why.

jhodgdon’s picture

RE #14 - http://api.drupal.org/api/drupal/modules!field!field.module/group/field/7
There are some issues to move this information elsewhere but it hasn't been done yet.

clemens.tolboom’s picture

@la2texas: the issue summary has #1230534: allowed_views should be an instance setting, not a field setting as initial problem. The patch over there maybe helps.

That page is indeed horrible http://api.drupal.org/api/drupal/modules!field!field.module/group/field/7 (and why is the link not formatted accordingly?)

@jhodgdon
- do you have these related issues?
- how it that page generated?

jhodgdon’s picture

RE #17 -
- API docs on api.drupal.org are generated by the API module from comments in the code.
- Not sure why that URL did not turn into a link; probably a bug in the core URL text formatter.
- Related issues:
#1391118: Clean up Field Types API topic and add settings form hooks
#1345654: hook_field_info should have clear link to the field_types topic, and that topic should say which hooks are needed

tim.plunkett’s picture

Priority: Major » Normal

This seems like it might change a bit after #1735118: Convert Field API to CMI.
Either way, not really a blocking major.

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.2.x-dev

Drupal 8 is end-of-life as of November 17, 2021. There will not be further changes made to Drupal 8. Bugfixes are now made to the 9.3.x and higher branches only. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.15 was released on June 1st, 2022 and is the final full bugfix release for the Drupal 9.3.x series. Drupal 9.3.x will not receive any further development aside from security fixes. Drupal 9 bug reports should be targeted for the 9.4.x-dev branch from now on, and new development or disruptive changes should be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

quietone’s picture

Status: Active » Closed (outdated)

Triaged at a triage meeting in #documentation.

hook_field_info was removed when fields became plugins, https://www.drupal.org/node/2064123.

I am marking this outdated.