Rewrite docs for EntityAutocomplete and DefaultSelection to make clear what config properties are used

Created on 27 September 2016, almost 8 years ago
Updated 18 February 2023, over 1 year ago

Problem/Motivation

The documentation in Form API's EntityAutocomplete class, of what properties are allowed in different configuration arrays, is difficult to find. Some properties are described in method docblocks; some on the class docblock; other docblocks are incomplete.

Proposed resolution

Rewrite inline documentation for EntityAutocomplete and DefaultSelection to clarify what property keys are permitted in config arrays:

* Move explanation of common config properties to class-level docblocks.
* Reference these in method level docblocks, to avoid duplication.
* Expand descriptions of properties where appropriate.
* Two classes to reference each other with @see, to avoid duplication.

Remaining tasks

Approve this issue summary change.

User interface changes

None.

API changes

None.

Data model changes

None.

πŸ› Bug report
Status

Needs work

Version

10.1 ✨

Component
DocumentationΒ  β†’

Last updated about 10 hours ago

No maintainer
Created by

πŸ‡§πŸ‡ͺBelgium Tronux

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    This issue is being reviewed by the kind folks in Slack, #needs-review-queue-initiative. We are working to keep the size of Needs Review queue [2700+ issues] to around 400 (1 month or less), following Review a patch or merge request β†’ as a guide.

    Documentation change looks like a good improvement.

  • Status changed to Needs work over 1 year ago
  • πŸ‡³πŸ‡ΏNew Zealand quietone New Zealand

    Always nice to see documentation improvements.

    +++ b/core/lib/Drupal/Core/Entity/Plugin/EntityReferenceSelection/DefaultSelection.php
    @@ -25,6 +25,18 @@
    + * Plugin configuration must contain a key handler_settings referencing an
    

    The first thing I noticed in this documentation was a double space. Then, I thought 'handler_settings' should be in quotes but then, as I read this, I think we can do better here. The descriptions should start with what the key is for, not the default value. And the reader should know what keys are required and which ones are optional, using the standard format. It is easier to express my ideas by example so I made a suggestion.

     * Available configuration keys.
     * - handler_settings: (required) An array with the following keys.
     *   - auto_create: (?) If TRUE, create referenced entities
     *     if they don't already exist. Defaults to FALSE.
     *   - auto_create_bundle: (?) Bundle name for auto-created entities, if
     *     auto-create is TRUE. Defaults to NULL.
     *   - sort: (?) An array of sort parameters. Default to ['field' => '_none'].
     *   - target_bundles: (?) An array of bundle names. Defaults to NULL. NULL means
     *     "allow entities from any bundle to be referenced"; an empty array
     *     means "no entities from any bundle can be referenced".
     *

    There is still work to do here. The text '(?)' needs to be replaced with (optional) or (required). And, maybe the description for target_bundles needs a tweak as well. It is not obvious why the two phrases are in double quotes.

    See Making lists in documentation β†’

  • πŸ‡¬πŸ‡§United Kingdom joachim

    target_bundles, sort, auto_create, auto_create_bundle are optional, since they default to something in defaultConfiguration().

    > * - sort: (?) An array of sort parameters. Default to ['field' => '_none'].

    We should say it's an array containing 'field' - the field name to sort on and 'direction' - one of ASC/DEC.

    Also, auto_create_bundle MUST be specified if auto_create is TRUE.

Production build 0.69.0 2024