Skip to content

Action's get_meta_fields(): using default values leads to unexpected behaviour #518

@sknopp

Description

@sknopp

Issue Overview

Using the following nested settings fields for my custom Action, if i uncomment the commented default values and then try to disable them in the backend configuration the following happens.

Instead of showing all options as disabled, the default values are getting applied again. This happens only, if one fully disables all of the given options at the same time. Configurations where at least a single option keeps enabled are working normally.

Steps to Reproduce (for bugs)

class Ticket_Mail_Action extends Action{
    // [...]
    public function get_meta_fields() {
        // settings fields for admin ui
        $meta_fields = parent::get_meta_fields();

        // mention that default values here lead to unexpected behaviour for fully disabled checkboxes
        $meta_fields['enabled_generators'] = array(
            'type'          => 'group',
            'label'         => __('Enabled generated Attachments', 'wp_torro_tickets'),
            'description'   => __('Please select, which Attachments should be automatically generated and attached.', 'wp_torro_tickets'),
            'fields'        => array(
                'pdf_ticket'    => array(
                    'type'      => 'checkbox',
                    'label'     => __('append ticket as PDF file', 'wp_torro_tickets'),
//                    'default'   => true
                ),
                'pkpass_ticket' => array(
                    'type'      => 'checkbox',
                    'label'     => __('append ticket as PKPass file', 'wp_torro_tickets'),
//                    'default'   => true
                ),
                'pdf_bill'      => array(
                    'type'      => 'checkbox',
                    'label'     => __('append bill as PDF file <i>(not yet implemented!)</i>', 'wp_torro_tickets'),
//                    'default'   => false
                )
            )
        );
//     [...]
     }
//   [...]
}

Screenshots / Video

Bildschirmfoto 2020-05-31 um 21 21 18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions