Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I have a custom module which defines a new widget. As far as I can tell, I cannot make FCS aware of my widget and the states it supports (at least not without hacking the module).
Can we have a way to alter the array coming out of _field_conditional_state_get_field_states()? A simple drupal_alter should suffice I guess.
Maybe I'm over-simplifying things, but I think exposing an alter hook would make it much easier for other contrib projects to support FCS. Maintainers wouldn't need to ask to be supported in this issue queue, they could simply implement it themselves.
Comment | File | Size | Author |
---|---|---|---|
#19 | add_hook-2270781-18.patch | 20.24 KB | Tobias Xy |
#2 | field_conditional_states.api_.php.txt | 2.07 KB | Tobias Xy |
Comments
Comment #1
Tobias Xy CreditAttribution: Tobias Xy commentedYes, I will add a hook for that. :-)
Comment #2
Tobias Xy CreditAttribution: Tobias Xy commentedI cleaned up the code a bit to be able to implement the hook hook_field_conditional_states_settings_alter.
See the field_conditional_states.api.php to learn how to use it.
I had to remove the tests, because they will be always successful now -> senseless.
Comment #3
Tobias Xy CreditAttribution: Tobias Xy commentedNew patch. Use hook_field_conditional_state_settings_alter instead of hook_field_conditional_states_settings_alter.
Comment #4
marcvangendI haven't tried it yet, but just seeing the code this looks very promising.
Just a thought: maybe it's a good idea to add static caching (or even database caching) in _field_conditional_state_get_element_settings(), so you don't have build the settings array and do a drupal_alter on it every time the function is called.
Comment #5
Tobias Xy CreditAttribution: Tobias Xy commentedTrue, that would be a good thing. New patch including static caching.
Comment #9
Tobias Xy CreditAttribution: Tobias Xy commentedComment #10
Tobias Xy CreditAttribution: Tobias Xy commentedComment #12
Tobias Xy CreditAttribution: Tobias Xy commentedYes, we don't have any tests currently... I know.
Comment #14
Tobias Xy CreditAttribution: Tobias Xy commentedI'm starting to hate the testbot...
Comment #15
hass CreditAttribution: hass commentedWhat does shs mean? Please add some inline documentation and never abbreviate... it hurts back somedays :-)
Testbot is the last line of defense against QA issues. :-)
Comment #16
Tobias Xy CreditAttribution: Tobias Xy commentedThats just the name of the widget as it is defined by Simple hierarchical select.
They abbreviated it, so I have to use it that way ;-)
The patches 9 and 12 should work exactly as 14 does. The testbot only didn't like it, that I removed the tests, because they are not longer needed with this patch.
Comment #17
Tobias Xy CreditAttribution: Tobias Xy commentedChanged title, still needs review.
Comment #19
Tobias Xy CreditAttribution: Tobias Xy commentedCommitted (a slighlty different patch to respect the recent changes).