I was reviewing #4509 and was playing with @indigoxela's PR on my local, trying to conditionally show/hide a warning if webp
was added to the list of allowed extensions for an image field instance.
A condition like this, where the value is "static" works fine:
'#states' => array(
'visible' => array(
':input[name="instance[settings][file_extensions]"]' => array('value' => 'png, gif, jpg, jpeg, webp'),
),
),
But the goal is to check the value of the field for any occurrence of webp
. Unfortunately, #states
doesn't seem to support regex OOTB
With some research, I've found this article: https://evolvingweb.ca/blog/extending-form-api-states-regular-expressions which would allow something like this:
'#states' => array(
'visible' => array(
':input[name="instance[settings][file_extensions]"]' => array('regex' => array('value' => '^.*webp.*$')),
),
),
Recent comments
Thank you for your support. Each of us embarked on our journey at different times, initially unaware of what Drupal and Backdrop CMS were. Over time, we’ve grown to understand and appreciate the...
Creating Submission Forms for Content Types
What a coincidence, I opened the same question as an issue earlier today, https://github.com/backdrop-contrib/tinymce/issues/177
Tiny MCE - Sticky Toolbar
I read several times, I did not understand what you want to do. Perhaps this is my problem. But... Each Content type has own creation form - '/node/add/content_type' (see page '/node/add')....
Creating Submission Forms for Content Types