Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
sknopp opened this issue May 31, 2020 · 0 comments

Comments

@sknopp
Copy link

sknopp commented May 31, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant