- Issue created by @ramil g
- Assigned to abhishek_virasat
- Issue was unassigned.
- Status changed to Needs review
9 months ago 9:50am 12 March 2024 - 🇮🇳India Vivek Panicker Kolkata
First of all, we get
$value == _none
only when we intially had given a value for the field and saved the content and later selected None from the options.
So I think that point needs to be mentioned in the description.
The first time we save the content without selecting any value in the term reference field, we get""
in $value.2nd point is regarding this code:
1. if ($element['#shs']['settings']['anyValue'] === reset($value)) { 2. if (!$element['#required']) { 3. return; 4. } 5. elseif (count($element['#options']) > 1) { 6. $form_state->setError($element, t('You need to select a term from the deepest level in field @name.', ['@name' => $element['#title']])); 7. return; 8. } 9. }
Even when there is
_none
in $value, still the code seems to return from line 2, since the element is not required.So I don't get the part where the error is occurring for you.
@Vivek, thanks for adding your comment. Sorry, yes the shs field does need to be required, I forgot to mention this above - I have updated the description. And yes there is this weird thing that happens where if you don't touch the dropdown and just have nothing selected, in the code the value shows up as an empty string, but if you just select something else, then change it back to the default, this changes the value to '_none' in the code. We noticed that if you are using Select2, this doesn't happen, the original value is set to '_none', and not ''.
This is why in my patch, in line 345, I had to add a condition to check if the value is empty to account for this: https://git.drupalcode.org/issue/shs-3427207/-/commit/3e4adfff57cb65db45...@abhishek - thanks for adding a patch but I actually did upload a patch yesterday but I used the new way of doing it, which is using git to commit to add the patch instead of uploading a patch file. You should see it above where it says "Issue fork shs-3427207"
- Merge request !27#3427207 Add some conditions in validateElement() in order to resolve some php 8 issues → (Closed) created by ramil g
- 🇨🇦Canada joelpittet Vancouver
@abhishek_gupta1 Thanks for the patch but ramil g had code already in there just missing the MR which he just created. The patch may have some gems but the coding standard whitespace makes it harder to see the fix. You could comment on the MR or change it if there are reasonable fixes to MR27 that would be helpful. I will hide your patch so it's less confusing.
- 🇮🇳India Vivek Panicker Kolkata
@ramil g, actually what I am trying to say is that I am not able to reproduce the issue on a fresh Drupal installation with only this contrib module installed.
So can I request you to try to reproduce the issue on a fresh installation and then note down the exact steps followed to reproduce the issue? -
joseph.olstad →
committed cb86ab4f on 2.0.x
Issue #3427207 by ramil g, abhishek_gupta1, joelpittet, Vivek Panicker:...
-
joseph.olstad →
committed cb86ab4f on 2.0.x
- Status changed to Fixed
8 months ago 6:07pm 22 March 2024 - 🇨🇦Canada joseph.olstad
The merge request fell behind and for some reason gitlab refuses to merge in that case.
Grabbed the patch from the MR and pushed it in, creditted everyone above. Automatically closed - issue fixed for 2 weeks with no activity.