Forum Replies Created

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • in reply to: nested conditional fields #3456
    mateo
    Member

    Resolved!

    I removed the nested group and applied the conditional test directly to each sub-fields and then updated the field values for each to unique names. Here is the new code:

    <?php
    /*
    Title: Video Row
    Setting: sp_theme_settings
    Tab Order: 1
    Order: 5
    */
    
    /*
     * Description: If the first select field (a conditional), 'show_homepage_video_block,' 
     * is changed to 'yes', then show the following field group, 'show_homepage_video_block.'
     *
     * The field group, 'show_homepage_video_block,' will contain a field (a file) to upload 
     * a static image (a placeholder for the video box; i.e. a video still) as well as another 
     * select field (a conditional), 'define_homepage_video_type,' to allow the user to define what 
     * kind of video asset should be inserted into the video box (either an uploaded video [using 
     * a file field] or an embedded video [using a html field]).
     *
     * However, I can not get the second conditonal to show the correct field, below is
     * my code:
     */
    
    // Conditional Setting: show/hide video block
    piklist('field', array(
        'type' => 'select',
        'label' => 'Show Video Block:',
        'description' => 'Show/Hide the video block on homepage.',
        'help' => 'Enable or disable a video block in the footer of the homepage. Preload with a static image placeholder for a better presentation.',
        'field' => 'show_homepage_video_block',
        'choices' => array(
            'yes' => 'Yes',
            'no' => 'No',
        ),
        'value' => 'yes',
    ));
    
    // Field Group: video values
    piklist( 'field', array(
        'type' => 'group',
        'label' => 'Set Video Values:',
        'description' => 'Use this section to upload and manage your video.',
        'help' => 'In this section you can uplaod a video still and upload a video or embed some video code from youtube or vimeo.',
        'conditions' => array(
            array(
                'field' => 'show_homepage_video_block',
                'value' => 'yes',
            ),
        ),
        'fields' => array(
            array(
                'type' => 'file',
                'label' => 'Upload A Video Still',
                'description' => 'This will be the image placeholder.',
                'help' => 'This image should be a screen grab of your video (a.k.a, a video still). Don\'t forget to add a title and a caption to the image after upload (this information will be display in a banner that appears on top of the image).',
                'field' => 'video_overlay_image',
            ),
            array(
                'type' => 'select',
                'label' => 'Video Type',
                'description' => 'Select the video to be added.',
                'help' => 'You can upload a video and host it yourself on this website or embed a video from a third-party source such as youtube or vimeo.',
                'field' => 'define_homepage_video_type',
                'choices' => array(
                    'embed' => 'Add Embed Code',
                    'upload' => 'Upload A Video',
                ),
                'value' => 'embed',
            ),
            array(
                'type' => 'file',
                'label' => 'Upload A Video',
                'description' => 'Upload your video.',
                'help' => '',
                'field' => 'video_type_value_upload',
                'conditions' => array(
                    array(
                        'field' => 'define_homepage_video_type',
                        'value' => 'upload',
                    ),
                ),
            ),
            array(
                'type' => 'textarea',
                'label' => 'Embed Video Code',
                'description' => 'Paste in your third-party embed code.',
                'help' => '',
                'field' => 'video_type_value_embed',
                'columns' => 12,
                'rows' => 5,
                'conditions' => array(
                    array(
                        'field' => 'define_homepage_video_type',
                        'value' => 'embed',
                    ),
                ),
            ),
        ),
    ));
    Attachments:
    You must be logged in to view attached files.
    in reply to: nested conditional fields #3455
    mateo
    Member

    Follow Up:

    I’m getting a “Warning: Illegal string offset ‘attributes’ in /Library/WebServer/Sites/sp-granduca/dist/wp-content/plugins/piklist/parts/fields/group.php on line 204”

Viewing 2 posts - 1 through 2 (of 2 total)