Tagged: conditional, contition, default, value
- This topic has 1 reply, 2 voices, and was last updated 4 years, 6 months ago by
Steve.
Viewing 1 reply thread
-
AuthorPosts
-
-
August 4, 2017 at 4:38 am #8344
riotxoaParticipantHi Piklist team,
I’m implementing some conditions to show or hide fields when those conditions’ values changes. The conditions are implemented through radio buttons and simple select lists.
Showing and hiding works fine, but i’m having troubles when i’m consulting a saved post with conditional values saved. If I change the value of a radio button, then the shown fields change correctly, but if I change back the radio button to its original status, then the value of the conditionally shown (and saved) field disappear (it appears blank).
Here is my code. If I change de first radio status to ‘No’, and then go back to ‘Sí’ (Yes), the others fields’ values reset:
piklist('field', array( 'type' => 'radio', 'field' => 'section01_hasbutton', 'label' => '¿Botón de enlace?', 'list' => false, 'value' => 0, // set default value 'choices' => array( 0 => 'No', 1 => 'Sí', ) )); piklist('field', array( 'type' => 'text', 'field' => 'section01_button_text', 'label' => 'Texto del botón de enlace', 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ) ) )); piklist('field', array( 'type' => 'select', 'field' => 'section01_buttonurltype', 'label' => 'Tipo de enlace', 'value' => 'url', 'choices' => array( 'url' => 'URL Externa', 'post' => 'Entrada de Blog', 'portfolio' => 'Portfolio', 'page' => 'Página' ), 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ) ) )); piklist('field', array( 'type' => 'url', 'field' => 'section01_button_url_url', 'label' => 'URL enlazada', 'columns' => 12, 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ), array( 'field' => 'section01_buttonurltype', 'value' => 'url' ) ) )); piklist('field', array( 'type' => 'select', 'field' => 'section01_button_post_url', 'label' => 'Entrada de Blog enlazada', 'choices' => piklist( get_posts( array( 'post_type' => 'post', 'numberposts' => -1, 'orderby' => 'post_date' ), 'objects' ), array( 'ID' ,'post_title' ) ), 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ), array( 'field' => 'section01_buttonurltype', 'value' => 'post' ) ) )); piklist('field', array( 'type' => 'select', 'field' => 'section01_button_portfolio_url', 'label' => 'Entrada de Portfolio enlazada', 'choices' => piklist( get_posts( array( 'post_type' => 'avada_portfolio', 'numberposts' => -1, 'orderby' => 'post_date' ), 'objects' ), array( 'ID' ,'post_title' ) ), 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ), array( 'field' => 'section01_buttonurltype', 'value' => 'portfolio' ) ) )); piklist('field', array( 'type' => 'select', 'field' => 'section01_button_page_url', 'label' => 'Página enlazada', 'choices' => piklist( get_posts( array( 'post_type' => 'page', 'numberposts' => -1, 'orderby' => 'post_date' ), 'objects' ), array( 'ID' ,'post_title' ) ), 'conditions' => array( array( 'field' => 'section01_hasbutton', 'value' => 1 ), array( 'field' => 'section01_buttonurltype', 'value' => 'page' ) ) )); -
August 12, 2017 at 10:30 pm #8349
-
-
AuthorPosts
Viewing 1 reply thread
- You must be logged in to reply to this topic.