This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

State emitter for checkbox

10 years ago · Last reply by Filipe 9 years ago

Hi,

How can I add a state emitter for checkbox field? E.g. show/hide another field when a single checkbox is checked!

Thank you for this amazing plugin and your support!

This is our free support forum. Replies can take several days.

Need fast email support? Get SiteOrigin Premium

Replies

2
  1. Greg Priday Staff 10 years, 1 month ago

    Hi Filipe

    Sorry for the late reply. I’m just coming off a little bit of a holiday :)

    I haven’t actually tested state emitters with a checkbox, but I imagine you could do this with a simple conditional state emitter. Something along the lines of

    'state_emitter' => array(
        'callback' => 'conditional',
        'args' => array(
            'group[active]: val',
            'group[inactive]: !val',
        )
    ),

    And then you’ll just need to handle that with a state handler – https://siteorigin.com/docs/widgets-bundle/form-building/state-emitters/#heading-state-handlers

    If the standard conditional state emitter doesn’t work for a checkbox, then you could also try a custom state emitter. This would give you fairly fine grained control over the state that’s emitted from the checkbox.

    https://siteorigin.com/docs/widgets-bundle/form-building/state-emitters/#heading-custom-callbacks

    As soon as I get a chance I’ll take a proper look at checkboxes and state emitters. So far, in our own widgets, we’ve only ever needed them for select fields.

  2. Filipe 9 years, 10 months ago

    Hi Greg, thank you for the answer.

    Unfortunately, it doesn’t work with the standard conditional state emitter, at least on my try!

    I want to create a simple switcher, and use the conditional state emitter to show/hide when button is on/off.. :(

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.

Have a different question or issue?

Start New Thread