Home>Support>State handler changing value of another field

State handler changing value of another field

Hi,
this is first time I’m using state emitters and hanlders and I was wondering how we can archive that state handler change value of some field. For now I’ve

				'image_type'    => array(
					'type'    => 'select',
					'default' => 'auto',
					'label'   => __( 'Choose type of image', 'oskyr_widget' ),
					'state_emitter' => array(
						'callback' => 'select',
						'args' => array( 'image_type' )
					),
					'options' => array(
						'full_width' => __( 'Full width', 'oskyr_widget' ),
						'product'      => __( 'Customizable', 'oskyr_widget' ),
					)
				),
				'max_width' => array(
					'type' => 'slider',
					'label' => __( 'Image max-width', 'oskyr_widget' ),
					'default' => 46.25,
					'min' => 0.1,
					'max' => 100,
					'integer' => false,
					'state_handler' => array(
						'image_type[full_width]' => array('hide'),
						'image_type[product]' => array('show'),
					)
				),
				'min_height' => array(
					'type' => 'slider',
					'label' => __( 'Image min-height', 'oskyr_widget' ),
					'default' => 12.5,
					'min' => 0.1,
					'max' => 100,
					'integer' => false,
					'state_handler' => array(
						'image_type[full_width]' => array('hide'),
						'image_type[product]' => array('show'),
					)
				),
				'height_type'    => array(
					'type'    => 'radio',
					'default' => 'auto',
					'label'   => __( 'Choose image height type', 'oskyr_widget' ),
					'state_emitter' => array(
						'callback' => 'select',
						'args' => array( 'height_type' )
					),
					'options' => array(
						'auto' => __( 'Auto', 'oskyr_widget' ),
						'static'      => __( 'Static', 'oskyr_widget' ),
					),
					'state_handler' => array(
						'image_type[product]' => array('hide'),
						'image_type[full_width]' => array('show'),
					),
				),
				'height' => array(
					'type' => 'slider',
					'label' => __( 'Select height of image element', 'widget-form-fields-text-domain' ),
					'default' => 350,
					'min' => 1,
					'max' => 1400,
					'integer' => true,
					'state_handler' => array(
						'height_type[auto]' => array('hide'),
						'height_type[static]' => array('show'),
						'image_type[product]' => array('hide'),
					)
				),

and that works almost perfect except that moment when we choose Image type as Full width, and Image height as Static, them change Image type to Cusotmizable and return to Full width. The reason of this is because state of field height type dosent changed, so field height is still hidden. As I read in docs we can use jQuery functions in state handlers, but radio input with height type will have random number in id and class so I cant refer to them by jQuery to use prop function.

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 9 years, 15 days ago Braam Genis
    Hi, I Work Here

    Hi Łukasz Ziaja

    Thanks for letting us know about this. I’ve logged this as a potential bug in our issue tracker. We’ll investigate this as soon as possible and try come up with a fix.

    Cheers
    Braam

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.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More