Add support for inline widget display

Created on 6 June 2019, over 5 years ago
Updated 24 February 2023, over 1 year ago

Hi,

We used this module for an internal project and we think the widget is great, but opening a modal was a bit too much for us. We rather have the option to display the widget inline just below the field the widget is enabled on.

I will attach a patch that will implement this feature.

I've considered making this two separate functions rather then returning early in the code. So maybe the patch should contains the following (this is just an idea):

  public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) {

    $arr_element = parent::formElement($items, $delta, $element, $form, $form_state);

    if ($this->getSetting('inline') == TRUE) {
        $this->addInlineSearchForm($arr_element);
    } else {
        $this->addModalSearchForm($arr_element);
    }

    return $arr_element;
  }

Let me know what you think.

Thanks in advance.

Feature request
Status

Needs work

Version

2.0

Component

Code

Created by

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.

  • 🇹🇭Thailand Nick Hope

    Re-roll for 2.1.0 and the current 2.x-dev, which upgraded the jsTree version, meaning patch #27 would no longer apply.

    Besides adding an inline widget, the patch also removes whitespace in entity_reference_tree_libraries.yml, as did patch #27.

  • Assigned to Nick Hope
  • Status changed to Needs work over 1 year ago
  • 🇹🇭Thailand Nick Hope

    No longer applies to 2.2.0. I will attempt to re-roll.

  • Issue was unassigned.
  • Status changed to Needs review over 1 year ago
  • 🇹🇭Thailand Nick Hope

    Re-roll for 2.2.0, required because the jsTree version changed from 3.3.14 to 3.3.15. The files entity_reference_tree_inline.js and InlineEntityReferenceTreeWidget.php still work in their original form from #27 and are unchanged. This patch does not include the jsTree version number, so hopefully another new patch should not be required if just the jsTree version changes.

    I would like to see this committed, but if it is never likely to be, perhaps it should become a separate module. @Mingsong, what are your thoughts?

  • 🇦🇺Australia mingsong 🇦🇺

    Hi @Nick,

    Thanks for working on it.

    As it is a big change from 2.x branch, I created a new branch called 3.x for any experiment new feature like this one.

    I also create a new fork and a new branch for this issue specificly.

    https://git.drupalcode.org/issue/entity_reference_tree-3059845/-/tree/30...

    Please free feel to work on this branch and create a merge request that aims to 3.x branch.

    Once we have the branch ready and tested by others. I am happy to release the 3.x branch to see how popular the new feature is.

  • Status changed to Needs work over 1 year ago
  • 🇦🇺Australia mingsong 🇦🇺

    At this stage, we need:

    1. Apply the patch to the feature branch.
    2. Create a merge request for merging the feature branch into 3.x branch.
    3. Test the feature branch.
    4. Merge into 3.x branch if it is tested and reviewed by the community.
    5. Release 3.x branch to allow more people to use it via Composer.
  • 🇦🇺Australia mingsong 🇦🇺

    Sorry forgot to mention that anyone is more than welcome to create your own module that works with this module.

    That is one of the reasons why we uses open source or Drupal, right?

Production build 0.71.5 2024