Problem/Motivation

In SHS for Drupal 7 we had the possibility to add new terms directly in the widget. For D8 this is still missing.

Proposed resolution

Add the functionality to add new terms to SHS for Drupal 8.
Instead of creating a custom dialog we could use the core dialogs which are simple, clean and easy to extend.

Remaining tasks

* write code
* write tests

CommentFileSizeAuthor
#70 66-70.diff14.28 KBsinn
#70 shs-add_new_term_functionality-2712115-70.patch18.34 KBsinn
#66 Create Pets _ Pets (1).png13.99 KBshashank5563
#66 shs-add-new-term-functionality-2712115-66.patch15.83 KBshashank5563
#60 Drupal-shs-add-term.png8.04 KBNick Hope
#60 Drupal-shs-correct-primitive-type.png19.72 KBNick Hope
#60 shs-add-new-terms-functionality-2712115-60.patch15.02 KBNick Hope
#58 No Guarda.JPG54.34 KBahurtado_20
#58 Diseño.JPG34.09 KBahurtado_20
#56 New_terms not working.png30.1 KBSummit
#54 SHS_add_new_greyed_out.jpeg49.99 KBSummit
#53 2712115-53-add-new-terms-functionality.patch17.96 KBnikathone
#52 interdiff_39-52.txt2.75 KBnikathone
#52 2712115-52-add-new-terms-functionality.patch17.93 KBnikathone
#40 shs-add-new-terms-functionality.patch14.17 KBcsedax90
#39 shs-add-new-terms-functionality.patch14.14 KBcsedax90
#35 shs-create-items-dev-2712115-35.patch13.25 KBpaulmckibben
#33 shs-create-items-dev-2712115-33.patch13.95 KBeme
#29 shs-create-items-dev-2712115-29.patch16.56 KBeme
#28 shs-create-items-dev.patch16.56 KBeme
#21 shs-create-items-dev-2712115-21.patch16.69 KBkriboogh
#18 shs-create-items-dev-2712115-15-p1-2.patch29.99 KBjeremdow
#17 shs-create-items-dev-2712115-15-p1.patch14.51 KBjeremdow
#15 shs-create-items-dev-2712115-15.patch31.24 KBkriboogh
#7 shs-create-items-dev-2712115-7.patch15.02 KBkriboogh
#6 shs-create-items-dev-2712115-6.patch20.92 KBkriboogh
#4 shs-create-items-dev-patch.diff13.88 KBkriboogh
#2 Screen Shot 2016-07-14 at 14.14.44.png21.07 KBkriboogh
#2 Screen Shot 2016-07-14 at 14.14.32.png23.7 KBkriboogh
#2 shs-create-items-dev-patch.diff145.39 KBkriboogh

Issue fork shs-2712115

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

stBorchert created an issue. See original summary.

kriboogh’s picture

We needed this for our current project so I implemented a possible solution. With the patch below it is possible to create items on the fly, inline. So no popup occurs (see screenshots).

Due to time limitations on our project, I'm not able to write tests for this.
Also note that maybe extra security stuff needs te be put in place since adding the new term is now exposed as a ajax url !

stBorchert’s picture

Status: Active » Needs work

Uhm, the diff doesn't look as it has been built on top of the latest git commit. It seems to contain all code from SHS.
Could you please create a new patch containing your changes only?
See https://www.drupal.org/node/1054616 for a guide.

kriboogh’s picture

FileSize
13.88 KB

Ah, sorry about that. I updated the file.

stBorchert’s picture

Thanks for the patch, I'll do an in-depth review when I'm back from my vacation ;)
Quick review without further testing:

  1. +++ b/modules/contrib/shs/js/views/WidgetView.js
    @@ -138,6 +143,61 @@
    +                var langcode = $('select[name="langcode[0][value]"]').val();
    

    Better not rely on a field that may be there (or not) ... passing the language as a setting would be cleaner IMHO.

  2. +++ b/modules/contrib/shs/js/views/WidgetView.js
    @@ -138,6 +143,61 @@
    +                      langcode: langcode || 'en'
    

    Why "en" as default language and not LanguageInterface::LANGCODE_NOT_SPECIFIED?

  3. +++ b/modules/contrib/shs/shs.routing.yml
    @@ -6,3 +6,10 @@ shs.term_data:
    +    _permission: 'access content'
    

    This should be something like "edit terms in {vocabulary}" or (even better) a custom permission callback which may be overridden on a per field base.

You've enabled "allow creating new levels" in the patch but this option is never used in the code?

kriboogh’s picture

Status: Needs work » Needs review
FileSize
20.92 KB

Patch updated, now includes crsf control on the ajax call and updated using a custom permission to check if user has rights to create a term in the vocabulary.

The "allow creating new levels" is used in the javascript to hide the widgets.

kriboogh’s picture

FileSize
15.02 KB

Updated to latest dev release (September 9th)

NWOM’s picture

Status: Needs review » Needs work

Thanks for #7! I successfully applied it without problems. However, I noticed one potential bug. When disabling "allow creating new levels", terms on the first (and only) level cannot be created either. I tested this when no terms were added to a vocab. Is this behavior intentional?

Edit: I noticed two additional issues while testing it. One issue is that sometimes when creating a new term, the term is not shown until the page refreshes. Also, if you have two fields that reference the same taxonomy vocab, create a term, and assign it; the second field will not show the new term until a refresh has occurred.

kriboogh’s picture

Behavior is not intentional, so I guess at a first level you should be allowed to create terms. Other issues you describe is something I didn't test so those are bugs as well.

Unless someone else likes to picks this up, I will look into this later on, as we don't need this behavior at the moment in our project, and time is really tight; so I can't spent time on this.

nicholas.alipaz’s picture

The only issue I am finding is that after creating a term it does not automatically select the term upon creation. This causes end-user confusion from UX perspective.

bmcclure’s picture

I may resolve this if I need that particular behavior to work in the meantime as well, but I'm pretty sure this patch is working well enough for my use case on my current project, and it's certainly an improvement over not having the option at all!

Update: I'm noticing the issue of the new term not being auto-selected as well. That's a more important issue to solve IMO as far as UX is concerned, and I may submit a patch shortly if I find time to solve it before someone else does.

bmcclure’s picture

I've discovered that it's this patch which causes some very wonky behavior involving Inline Entity Forms (I think).

I'm using Commerce, which uses IEF to manage product variations. I'm also using Entity Browser on several fields both on the product and the product variation (though this issue exists even with entity_browser uninstalled).

With this patch for SHS applied, this behavior starts happening:

1. Trying to open an entity browser from within the product variation (the IEF reference field) opens the wrong entity browser from a field on the parent product.
2. Disabling the entity browsers from the parent product field then causes the entity browsers from the variation to just not open or do anything at all.
2. Clicking Edit on a product variation and then clicking Cancel causes the entire Variations field to disappear from the edit form until the page is refreshed.

It seems like AJAX requests related to IEF are where the problem is coming from with this patch applied, but I don't know for sure why yet.

SakaSerbia’s picture

One question. I install 8.x-1.x-dev from 2016-Sep-09. Is this patch add to last version or no?

For me its look like there si no function create new items http://prntscr.com/ddfpml

EDIT: I install patch and for me its look that all work good. If I see some issue I would write..

nicholas.alipaz’s picture

The November 30th code changes broke the patch and it no longer applies cleanly. Needs a re-roll.

kriboogh’s picture

FileSize
31.24 KB

Here is a patch against the latest dev (nov 30th)
Note: None of the issues mentioned about have been addressed, this is just to apply the original patch to the latest dev.

@nicholas.alipaz when creating a new item, in my case it selects the new item automatically (using safari on mac OSX). Maybe this is browser related?

jeremdow’s picture

Thanks, kriboogh, can you re-roll one more time though at the original patch level?

Composer only checks p0-p2 levels deep, so this is failing to apply again for me.

jeremdow’s picture

Actually, never mind, here it is - thanks again.

jeremdow’s picture

Oops, try that again - not sure why it got truncated.

nicholas.alipaz’s picture

This patch is causing another ajax widget from paragraph to silently fail. Uninstalling this patched module restored my functionality. There are no log entries and nothing in my js console to indicate what is happening.

nicholas.alipaz’s picture

Reading through the patch I wonder if the fact it is disabling some form caching might be having an effect. The issue I am having is very similar to what bmcclure describes in #12.

Here is where I documented the issue I am having in paragraphs when this patch is applied.

kriboogh’s picture

Small fix we needed to get https working (patched against the latest dev 8.x-1.0-alpha2+2-dev)

nicholas.alipaz’s picture

As per #2833573: Clicking remove does not re-display the selection widget, I did confirm this patch to be the issue with a caching problem I had on multiple ajax driven widgets. Removing this patch fixed my issue on other form widgets.

stBorchert’s picture

Side note: I would love to see the form extensible so a developer could easily add a language dropdown or some other fields necessary for the term generation.
And as a bonus: use a popover :)

Aparnag’s picture

Very useful patch #7

rashad168’s picture

I tried to use #18 jeremdow patch with the last dev version (8.x-1.0-alpha2+11-dev) but I face this issue

- in my terminal when I apply the patch there is some file patching FAILED as you see below:

patching file js/models/WidgetModel.js
patching file js/views/AppView.js
patching file js/views/ContainerView.js
patching file js/views/WidgetView.js
patching file shs.module
Hunk #1 FAILED at 79.
1 out of 1 hunk FAILED -- saving rejects to file shs.module.rej
patching file shs.routing.yml
patching file src/Controller/ShsController.php
Hunk #1 FAILED at 2.
Hunk #2 succeeded at 77 (offset -3 lines).
1 out of 2 hunks FAILED -- saving rejects to file src/Controller/ShsController.p hp.rej
patching file src/Plugin/Field/FieldWidget/OptionsShsWidget.php
Hunk #1 FAILED at 2.
Hunk #2 succeeded at 91 (offset 44 lines).
Hunk #3 succeeded at 102 (offset 44 lines).
Hunk #4 succeeded at 145 (offset 44 lines).
Hunk #5 succeeded at 168 (offset 44 lines).
Hunk #6 FAILED at 143.
Hunk #7 succeeded at 195 (offset 38 lines).
Hunk #8 succeeded at 323 (offset 43 lines).
2 out of 8 hunks FAILED -- saving rejects to file src/Plugin/Field/FieldWidget/O ptionsShsWidget.php.rej
patching file modules/patched/shs.patch

- this failed patching file return an error message in the website as below:

The website encountered an unexpected error. Please try again later.
Recoverable fatal error: Argument 1 passed to Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget::getOptions() must be an instance of Drupal\shs\Plugin\Field\FieldWidget\FieldableEntityInterface, instance of Drupal\node\Entity\Node given, called in C:\wamp\www\altamayoz\core\lib\Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget.php on line 34 and defined in Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget->getOptions() (line 335 of modules\shs\src\Plugin\Field\FieldWidget\OptionsShsWidget.php).

Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget->getOptions(Object) (Line: 34)
Drupal\Core\Field\Plugin\Field\FieldWidget\OptionsSelectWidget->formElement(Object, 0, Array, Array, Object) (Line: 152)
Drupal\shs\Plugin\Field\FieldWidget\OptionsShsWidget->formElement(Object, 0, Array, Array, Object) (Line: 121)
Drupal\shs_chosen\Plugin\Field\FieldWidget\OptionsShsChosenWidget->formElement(Object, 0, Array, Array, Object) (Line: 322)
Drupal\Core\Field\WidgetBase->formSingleElement(Object, 0, Array, Array, Object) (Line: 85)
Drupal\Core\Field\WidgetBase->form(Object, Array, Object) (Line: 168)
Drupal\Core\Entity\Entity\EntityFormDisplay->buildForm(Object, Array, Object) (Line: 122)
Drupal\Core\Entity\ContentEntityForm->form(Array, Object) (Line: 113)
Drupal\node\NodeForm->form(Array, Object) (Line: 117)
Drupal\Core\Entity\EntityForm->buildForm(Array, Object)
call_user_func_array(Array, Array) (Line: 514)
Drupal\Core\Form\FormBuilder->retrieveForm('node_properties_form', Object) (Line: 271)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)
Drupal\Core\Entity\EntityFormBuilder->getForm(Object) (Line: 113)
Drupal\node\Controller\NodeController->add(Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 576)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 124)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
call_user_func_array(Object, Array) (Line: 153)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 68)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 657)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

this patch can be applied to version (shs-8.x-1.0-alpha2) BUT this version conflict with many of other module like (inline entity form module), (field collection module) and also conflict with the image field when you try to upload multi image file it's save only 1 image.

so we need this PATCH to be apply to the last dev version (8.x-1.0-alpha2+11-dev) if it's possible

rashad168’s picture

after some testing I fond that both shs version (shs-8.x-1.0-alpha2) and (8.x-1.0-alpha2+11-dev) are working found but without the (functionality to add new terms) and if we apply this PATCH the add new term functionality is working but make the shs module conflict with other modules like below:

- issue of image field with this patch:
when we upload multi image when we save the node only 1 image its view in that node

- issue of field collection module with this patch:
if we use field collection and we use unlimited item functionality we can't add more than 2 items and when we save the node only 1 item is saved the 2nd item disappear

- issue of inline entity form module with this patch:
if we try to add new node thru inline entity form field, the field not saved and disappear after we click the create node link

I could not figure out why this conflict behavior appear?

eme’s picture

Issue come from

// Don't cache because we get illegal choice errors if new items are created.
    //$form_state->disableCache();

If you delete this, you will get rid of strange errors. I did not get illegal choice errors for my part, but that may be occur in some cases (to be defined).

eme’s picture

FileSize
16.56 KB

Attached patch.

eme’s picture

FileSize
16.56 KB

Sorry, well named patch.

kriboogh’s picture

Can confirm that using #28, by removing the disableCache, we no longer get the illegal choice errors.

rashad168’s picture

yes, I tried #29 patch with version " 8.x-1.0-alpha2 " on two different site it's work fine thank you very much..
and I want to inform that #29 patch not compatible with 8.x-1.x-dev

mikejw’s picture

The patch doesn't apply easily either using `git apply` or `patch -p1` - could you please create it using git (instead, I am assuming, using your IDE)? @eme

eme’s picture

Can you try with this one ?

mikejw’s picture

Sadly that doesn't work either so I tried to hand patch what you have against the latest dev and I can see that it won't apply at all - for starters the shs.module has changed quite a bit. Ideally you need to be doing a git clone from the dev version, perhaps making a branch, make your changes in the new branch and then you can do something like `git diff 8.x-1.x > name-of-issue.patch`.

The version control page for the module covers it pretty well: https://www.drupal.org/project/shs/git-instructions

paulmckibben’s picture

I've hand-entered and rerolled the patch from #33 against the latest 8.x-1.x branch. However, it needs work: the user interface doesn't provide good feedback that the new term was created. That said, this is a good baseline from which to refine and improve. @eme, thanks for your work so far!

paulmckibben’s picture

Another problem: when editing an existing entity, the field allows me to specify a new term even if I've specified that creating new terms is not allowed.

Anonymous’s picture

paulmckibben, the patch in your comment #35 fails:

patching file js/models/WidgetModel.js
patching file js/views/AppView.js
patching file js/views/ContainerView.js
patching file js/views/WidgetView.js
patching file modules/shs_chosen/shs_chosen.info.yml
Hunk #1 FAILED at 4.
1 out of 1 hunk FAILED -- saving rejects to file modules/shs_chosen/shs_chosen.info.yml.rej
patching file shs.routing.yml
patching file src/Controller/ShsController.php
patching file src/Plugin/Field/FieldWidget/OptionsShsWidget.php

Upon selecting the appropriate field form display settings to make use of the modification, it produces an error when going to the "add content" page:

The website encountered an unexpected error. Please try again later.

Report Log shows this:

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "shs.create_term" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 201 of /volume1/Web/website.com/core/lib/Drupal/Core/Routing/RouteProvider.php).

how did you get it working?

Anonymous’s picture

upon testing and getting this to "work" using the scripts and various versions (tested all patches and all alpha versions), I've come to the conclusion that the addition of new terms is not possible on the FIRST layer of a taxonomy vocabulary?

can anyone confirm?

the modification does not allow me to add any terms to the list if there is only one level of terms. the dialog box never pops up.
using the alpha2 version will not work on drupal 8.6, as it produces a "taxonomy_term_hierarchy' doesn't exist: " error in the error log.
so this feature seems to be dead in drupal 8 for anyone that decides to update.

shame. it's a much needed feature.

does anyone know of a similar module that has similar capabilities?

csedax90’s picture

I've merged #35 with latest dev and added some improvements... it is certainly not a nice and clean code but at least it works

I've solved a problem with multiple term selection and the disappearing issue when you select an empty select after the first render... I hope I have been helpful

csedax90’s picture

FileSize
14.17 KB

Rerolled #35 + some improvements

balbogbf’s picture

hi, i have the same problem of #37

Symfony\Component\Routing\Exception\RouteNotFoundException: Route "shs.create_term" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 201 of /volume1/Web/website.com/core/lib/Drupal/Core/Routing/RouteProvider.php).

an idea? tks a lot!

rwilson0429’s picture

The patch in #40 applied cleanly but I'm still unable to add new terms from the node/add or node/edit screen.

  • I setup a Taxonomy Term reference field on the Article content type and selected the SHS as the field widget.
  • On the Manage Form display on the Article content type, I have set the shs form widget to 'Allow creation of new items' and 'Allow creation of new levels' and 'Do not force selection of deepest level'.

However, I'm still not able to add new terms from the node/add or node/edit pages.

csedax90’s picture

try the #39, I found some bugs with the #40 that I still have to solve

kars4’s picture

Hello,

I need let users to select or create hierarchical taxonomy terms if not exist in content add form.
SHS module providing the required functionality, but doesn't work in Drupal 8.7

Can anyone to fix it?

Thanks

coozila’s picture

Will be nice to work!

phrk’s picture

As mentioned above and in 3067029, none of the patches work in Drupal >= 8.7 .

rwilson0429’s picture

#39 works from me with a clean install of Drupal 8.8.2

sfuchsbe’s picture

@rwilson0429: don't know what you did different... I installed a fresh Drupal 8.8.5, enabled SHS 8.x-1.x-dev + patch #40.
I used the existing entity reference field for the tags vocabulary in the article content type and set this to use SHS as form widget with adding new terms set to allowed. The field itself is by default configured to allow creation of new fields. When opening a node add or edit form the widget appears, I can select out of existing terms but there is no option present to add new terms.
When using #39 as mentioned in your post the entire widget is not appearing in the forms.
Probably you could explain more detailed what you were doing to be able to reproduce.
@sedax: probably you can double check #40. You mentioned you wanted to provide another update. Would highly appreciate any input. In parallel I'm going to double check as well.

I tried again and for some reason now #39 is working as expected. Don't know what went wrong the first time. So all good and just ignore my post ;)

Thank you

selpe’s picture

Thanks sedax...

Rar9’s picture

Will this still work for d9?

ShaneOnABike’s picture

I can confirm that #39 is working. Is it possible to roll this into the latest dev of make a new release?

nikathone’s picture

Status: Reviewed & tested by the community » Needs review
FileSize
17.93 KB
2.75 KB

Patch working with Drupal 9. Had to remove entity.manager and some other minor cleanup.

nikathone’s picture

FileSize
17.96 KB

Oops. Uploaded wrong patch file. Since this patch is adding a router the user will need to clear the cache before trying to add a term.

Summit’s picture

FileSize
49.99 KB

Hi,
I tried this patch on my dev environment. There it is working great.
Then I copy-paste the whole site, with the database to my production environment. There I do not see the function to add new terms.
And the options to add new terms are greyed out in the screen at admin/structure/types/manage/listing/form-display (see picture)

I also added the patch to save term lineage (https://www.drupal.org/project/shs/issues/2943357) , hopefully these two do not interfere. Unfortunately I do not see an error message.
But no possibility to add new terms on node edit page on my production site.
Using latest Drupal 8, and latest .dev version of SHS.
greetings,

d.sibaud’s picture

Unfortunately, after applying the patch the "Add new term" shows up also on views exposed filters and it is available for all the users without any regard to user permissions (however I don't expect to see it on views exposed filters at all).

Summit’s picture

FileSize
30.1 KB

Hi, It is on live site not working. Latest Alpha, this patch, and latest Drupal 8. Taxonomy not limited.
I can not select the option add new terms.

See attached image. Thanks for looking into this still. Would be great if this was working!
Greetings, Martijn

Summit’s picture

Hi,
Sorry, I can add select the option, but it is just not showing the "add new" within the term selection.
greetings, Martijn

ahurtado_20’s picture

FileSize
34.09 KB
54.34 KB

Hi, I'm looking for help, when I try to create two SHS terms, the second one doesn't work, it doesn't save my webform, what can I do?

stBorchert’s picture

Version: 8.x-1.x-dev » 2.0.x-dev

Moving to new branch.
Note for anyone working on this: #2712115-23: Add functionality to add new terms ;)

Nick Hope’s picture

Status: Needs review » Needs work
FileSize
15.02 KB
19.72 KB
8.04 KB

#53 applies to 8.x-1.0-alpha5. I needed to do a drush cr (not just clear caches) to get it working.

It does work, but unfortunately it enables new terms to be added for every term-reference field on the page, even if "Allow creating new items" is unchecked for some fields.

SHS add term

This patch #60 is a re-roll for 2.0.x-dev. It has the same problem as above, and also, if I save a media entity, without setting some non-required fields, I get the error "This value should be of the correct primitive type."

SHS correct primitive type

Regarding #55, I didn't see "Add new term" on any of my exposed filters. Maybe that refers to an older patch. (see #62)

Nick Hope’s picture

Nick Hope’s picture

Just an update to say that I did start seeing "Add new term" on my exposed filters, so that's still an issue.

Until that is fixed, the patch is still useful for administrators wanting to add a lot of media and a lot of taxonomy terms at the same time.

Summit’s picture

Hi, Could this great functionality be added to version 2.x also please for Drupal 9?
Thanks for this in advance!
greetings, Martijn

aiphes’s picture

I need the ability to add terms on the fly on a D9.2.10 website and actually the option

" Allow creating new items
Allow users to create new items of the source bundle."

is unavailable.
Both on 2.0dev and RC version.
Is this planned or scheduled for next months ?

Thanks

Summit’s picture

Hi, on RC1 with latest Drupal 9.3.0 I got error:

: Got error 'PHP message: Error: Using $this when not in object context in httpdocs/web/modules/contrib/shs/src/Plugin/Field/FieldWidget/OptionsShsWidget.php on line 383 #0 [internal function]: Drupal\\shs\\Plugin\\Field\\FieldWidget\\OptionsShsWidget::validateElement()\n#1 

When I look into solutions, I think we have to move to .dev version.

Could this patch be altered as such it works on latest .dev?

Thanks a lot in advance,
greetings, Martijn

shashank5563’s picture

#60 I have made some minor changes in the patch and it working perfectly with 2.0.0-rc3 version in drupal 9.

Patch working with Drupal 9.
term

aiphes’s picture

Trying to apply the patch and I get on Drupal 9.4.8 :

modules/contrib/shs [2.0.x|✔] 
$ curl https://www.drupal.org/files/issues/2022-11-12/shs-add-new-term-functionality-2712115-66.patch | git apply
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 16210  100 16210    0     0  37610      0 --:--:-- --:--:-- --:--:-- 37610
<stdin>:154: trailing whitespace.
<stdin>:161: trailing whitespace.
                  $('.shs-container').append('<div class="messages messages--status append_message">Select newly added '  + data.vocabulary_label + ' From Drop down List</div>');  
<stdin>:166: trailing whitespace.
<stdin>:170: trailing whitespace.
<stdin>:327: trailing whitespace.
warning: 5 lines add whitespace errors.

and when I try to edit a content which use the shs field:
Symfony\Component\Routing\Exception\RouteNotFoundException: Route "shs.create_term" does not exist. in Drupal\Core\Routing\RouteProvider->getRouteByName() (line 206 of core/lib/Drupal/Core/Routing/RouteProvider.php).

sinn made their first commit to this issue’s fork.

sinn’s picture

Status: Needs work » Needs review
FileSize
18.34 KB
14.28 KB

I've updated the solution from #66 and created a merge request (attached patch is the latest version of the changes in MR):
- cleaned up a code a little bit.
- made the create_new_items setting processable in js (so you can enable/disable creation of the new items).
- implemented dependency injection.
- fixed langcode handling for term creation.
- removed input text field from views filter since term shouldn't be created on the views page.

abelass’s picture

On drupal 10.2 #patch70 allows me to select "Allow creating new items" and "Allow creating new levels" but I have no additional options in the node edit form

Summit’s picture

Hi Abelass, with this patch you can! I have let it build by a great company Drudesk.
https://www.drupal.org/project/shs/issues/3409930
greetings,

abelass’s picture

Thanks @Summit,

indeed it works with the 2 additional patches.

Summit’s picture

You are lucky, I waited 2 years for it...and then decided to let it build...
greetings and great weekend,

joseph.olstad’s picture

@everyone above:

I just became maintainer of this project.

Which patches are needed?

Anyone willing to take the onus for RTBC and explain which patches are needed? I hear a report about 2 additional patches, which patches are those? 2 additional patches would tell me there's three patches, which three patches?

Can someone please clarify?

joseph.olstad’s picture

  • joseph.olstad committed f2965705 on 2.0.x
    Issue #2712115 by kriboogh, eme, nikathone, jeremdow, csedax90,...
joseph.olstad’s picture

Status: Needs review » Fixed

took patch 66

  • joseph.olstad committed 88d1cda4 on 2.0.x
    Revert "Issue #2712115 by kriboogh, eme, nikathone, jeremdow, csedax90,...
joseph.olstad’s picture

Status: Fixed » Needs work
joseph.olstad’s picture

Version: 2.0.x-dev » 3.0.0-alpha2

This bug was brought into 3.0.0-alpha1/alpha2