State Emitters Use ? Some Example ?
Hi, i love your plugn.
I’d like help to use State Emitters Functions.
If for example i have:
'slider_type' => array( 'type' => 'radio', 'label' => __( 'Select type of Slider', 'widget-form-fields-text-domain' ), 'options' => array( '1' => 'Slider 1', '2' => 'Slider 2' ), 'default' => '1' ),
And i wanna that selecting option with value = ‘2’ my widget shows:
'slider_2' => array( 'type' => 'select', 'label' => __( 'Select Slider 2', 'widget-form-fields-text-domain' ), 'options' => $array_slides2 ),
How can i do it ??
Thanks
This is our free support forum. Replies can take several days.
Need fast email support? Get SiteOrigin Premium
Replies
2Hi Francesco
Awesome to see you’re developing for the Widgets Bundle! And especially awesome to see you’re using state emitters. It’s a really powerful new feature we added in a recent update.
So the first step will be to attach a state emitter to your slider_type field. This will emit the state to the rest of the form.
The next step is to add a state handler to your slider_2 field. This will handle the slider_type state by showing the field if this state is set to 1 and showing it if it’s set to 2.
'slider_2' => array( 'type' => 'select', 'label' => __( 'Select Slider 2', 'widget-form-fields-text-domain' ), 'options' => $array_slides2, 'state_handler' => array( 'slider_type[1]' => array('hide'), 'slider_type[2]' => array('show'), ) ),Hope that points you in the right direction. Here’s a complete guide on using state emitters – https://siteorigin.com/docs/widgets-bundle/form-building/state-emitters/
Thanks ! It works perfectly !
Replies on this thread are closed.
Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.