- Issue created by @kopeboy
- ๐ฎ๐นItaly kopeboy Milan
Actually in case 2, even if the field state appears to be defined in the UI, when you go to the entity add form and try to trigger it, it doesn't work and this warning in thrown:
Warning: Trying to access array offset on value of type null in Drupal\field_states_ui\FieldStateBase->applyState() (line 75 of /var/www/html/web/modules/contrib/field_states_ui/src/FieldStateBase.php)
- ๐บ๐ธUnited States TolstoyDotCom L.A.
I looked into this a bit and I can do more on request.
Click the gear icon on admin/structure/types/manage/article/form-display next to the Title field.
In Manage Field States, choose 'Enable' and click 'Add'.At that point, this code from FieldStateManager::settingsForm will set $type to 'enabled':
$type = $form_state->getValue([ 'fields', $field_name, 'settings_edit_form', 'third_party_settings', 'field_states_ui', 'form', 'type', ]);
That's because 'third_party_settings' in form_state is like this:
Array ( [field_states_ui] => Array ( [form] => Array ( [type] => enabled [list] => [NULL] [add] => Drupal\Core\StringTranslation\TranslatableMarkup ) ) )
Then, change 'Comparison Type' to 'filled' and it throws a (silent) exception because there's no 'type' key in the 'third_party_settings' array:
Array ( [field_states_ui] => Array ( [form] => Array ( [edit] => Array ( [target] => uid [comparison] => filled [value] => [NULL] [submit] => Array ( [save] => Drupal\Core\StringTranslation\TranslatableMarkup [cancel] => Drupal\Core\StringTranslation\TranslatableMarkup ) ) [list] => [NULL] ) ) )
The missing 'type' key leads to "The "" plugin does not exist..."
- ๐ฆ๐บAustralia pasan.gamage
I've been running in to the same error but with "Visible" option.
I'm running into this problem as well for my project, but weirdly enough not on all environments. So I'm nopt sure it I'm experiencing a different error but I do have a boolean field used to toggle other fields.
I get the following error in the log:
TypeError: array_keys(): Argument #1 ($array) must be of type array, null given in array_keys() (line 238 of /web/modules/contrib/field_states_ui/src/FieldStateManager.php)
So it breaks in generating a notice
if (!isset($target['#field_parents'])) { $parents = []; $this->logger->notice( t( '#field_parents key not found. This will may cause problems. If so, please report on the @link. For quickest resolution, please include the element details: @details', [ '@link' => Link::fromTextAndUrl( t('Field States UI Issue Queue'), Url::fromUri('https://www.drupal.org/project/issues/field_states_ui') )->toString(), '@details' => var_export(array_keys($element[0]),TRUE), ] ) )
I mean, I can easily just patch that the var_export isn't used if $element[0] is NULL and yes then the field_state works as expected.
But I'm guessing the real questions is why $element[0] is NULL in this context. I don't have an answer right now since I haven't debugged it (yet).- ๐บ๐ฆUkraine Serhii Shandaliuk
Any workarounds how we can solve it? I have the same issue with the user's entity.
- ๐ฎ๐นItaly kopeboy Milan
ended up using the conditional_fields module..
- ๐บ๐ธUnited States Topplestack Rural, Idaho
I'm getting this error message regardless at the moment. Whether on a simple text field, boolean, text list, number, etc.
- ๐จ๐ฟCzech Republic parisek
I get same error with current Drupal 10.1.5. Adjusted priority to critical because module is unusable.
- ๐บ๐ธUnited States alex.verhoeven
Experiencing exactly the same issue. Only if I leave the Target and Comparison fields untouched and then save, does it add the state. I am not able to change either field, or edit an existing state. If I try to edit the existing state, I get:
Drupal\Component\Plugin\Exception\PluginNotFoundException: The "" plugin does not exist. Valid plugin IDs for Drupal\field_states_ui\FieldStateManager are: required, visible, collapsed, unchecked, invisible, optional, checked, enabled, expanded, disabled in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).
- ๐ง๐ฉBangladesh linkanp
I am getting extactly the same issue as alex.verhoeven This issue needs to be resolved.
- ๐บ๐ธUnited States sascher
We are seeing this issue also. We have a new install of the module on Drupal v 10.2.0
- ๐ฉ๐ชGermany zuernbernhard
Once you choose something in the third-party-settings form for comparison (eg value) or target (other field) - an Ajax Call is made to rebuild the form and the form state with the new plugin type information for the third party settings is gone
- ๐ฉ๐ชGermany hauke-vq Berlin, Germany
Most simply solution for now is just to disable the javascript while configuring the states.
But a patch for this is pretty wanted. - ๐ง๐ฉBangladesh linkanp
I have bypassed this issue by creating config yaml files manually for the new Field States. If anyone want, I would share my code with them.
- ๐จ๐ฆCanada briskly
@linkanp - care to share your approach? I've been scratching my head for days now.
- ๐ต๐นPortugal adaragao
I'm using the Brave browser, so I just went to the "Shields" Option ( Lion head on address bar), and activated the option "Block Scripts". Then I as able to do the conditions. I'm sure that other browsers have similar options.
- First commit to issue fork.
- Merge request !10Include type as a hidden form element to make it available in $form_state โ (Open) created by jofitz
- last update
7 months ago 23 pass, 24 fail - Status changed to Needs review
7 months ago 6:02pm 19 April 2024 - ๐ฌ๐งUnited Kingdom jofitz
I have simplified the issue title because it appears to affect more than just Boolean fields.
I think 2 separate issues are being discussed here.
- I have created an MR to fix the
The "" plugin does not exist
bug. - I have created a new issue, with an MR, ( ๐ Unable to change either the Target or Comparison elements Needs review ) to address the bug with being unable to change either the Target or Comparison elements (first mentioned by @alex.verhoeven, #3371927-12: PluginNotFoundException: The "" plugin does not exist โ )
- I have created an MR to fix the
- ๐ฎ๐ณIndia narendragupta
I am also facing the same issue while adding the visible field state.
Need patch fix. - ๐บ๐ฆUkraine nginex
Applying a patch from ๐ Unable to change either the Target or Comparison elements Needs review fixes the issue for me, so the module works well afterwards
- ๐ฎ๐ณIndia prashant.c Dharamshala
I also face the same issue on
10.3.x
. I will also try to review this MR. Thanks! - ๐ฎ๐ณIndia ravranjanim Bangalore
I am also facing same issue while selecting target ID and compression type on manage field state.