What should one write in the custom selector box? Custom function name and define it in code? Regular expression?
Custom selector

Thank you!

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

hkirsman created an issue. See original summary.

hkirsman’s picture

Issue summary: View changes
hkirsman’s picture

Issue summary: View changes
hkirsman’s picture

By accident found that it seems to be css selector. May be add example there or more info?

jrockowitz’s picture

Drupal's #states API allows you to enter any type of selector for a #states trigger. These custom triggers selectors are not processed via server-side validation.

If an input which is being used for a #state is deleted its selector will appear in 'Custom selectors' as ':input[name="ELEMENT_KEY"]'

A few thoughts...

  • The current implementation is the most flexible solution
  • #states API selectors could be checked and cleaned up on save
  • Deleted elements that are being used a selector will break an element's conditional logic
  • When an element is deleted we might be able to remove all references from the form's #states

I am open to suggestions.

hkirsman’s picture

I don't know how to make the functional part better but rather how user, coming to the admin page for the first time, should understand what to do there with the custom selector.

jrockowitz’s picture

Status: Active » Needs review
FileSize
123.84 KB
2.11 KB

How about we just remove support for custom selector? If someone enters a custom selector in YAML it will be appended to select menu.

The attached patch is going to break some tests which should be easy to fix.

Status: Needs review » Needs work

The last submitted patch, 7: 2938814-7.patch, failed testing. View results

jrockowitz’s picture

Status: Needs work » Needs review
FileSize
9.54 KB

  • jrockowitz committed 13878d4 on 8.x-5.x
    Issue #2938814 by jrockowitz, hkirsman: How does the "Custom selector"...
jrockowitz’s picture

Status: Needs review » Fixed
hkirsman’s picture

I would have seen something like instead of "Enter custom selector..." placeholder something like "Enter CSS selector...". Or write longer help sentence below the input. It's nice feature, why remove it.

jrockowitz’s picture

It made no sense because custom selectors were not supported via server-side conditional logic. Non-technical users would have no idea how it works. I literally could not think of a reasonable example of when anyone would use a custom selector.

Anyone who understands Drupal's #states API can still enter custom selectors via the YAML source editor and they will work as expected.

hkirsman’s picture

We need to make a condition based on some variable from the system. It's not perfect but we'll add hidden form element and check the variable from there.

I'm technical person and it didn't make sense to me too :P But it was because the text was so generic.

jrockowitz’s picture

Yes, it has crossed my mind to allow tokens to be used as selector/trigger.

If would be really cool if we could hide/show/require an element based on the current user's language.

I have absolutely no idea how we would set this up.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.