• Resolved saxpaolo

    (@saxpaolo)


    Hello, sorry to bother for such a general and maybe stupid question (perhaps I missed something in my settings), but I can’t find answers anywhere.

    I’ve created an CMB2 option page with some text input fields, as i usually do. Everything works fine, but I’ve noticed that I can’t delete the input fields contents. Once a text string is written and saved, if then I delete it (leaving the input text field blank) and save again, the previous store data come up again, and the frontend do not change.

    Again, surely I’m missing something

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Can you provide your CMB2 code to get this page set up, so that we can give it a try on our end for what you’re experiencing

    Thread Starter saxpaolo

    (@saxpaolo)

    …yep, you’re right, sorry…

    $prefix = '_themename_options_';
    
    $main_options = new_cmb2_box(array(
        'id' => $prefix . 'main_options_page',
        'title' => esc_html('Options title', '_themename-site'),
        'object_types' => array(
            'options-page'
        ),
        'context' => 'normal',
        'priority' => 'high',
        'option_key' => '_themename_main_options', // The option key and admin menu page slug.
        'icon_url' => 'dashicons-building', // Menu icon. Only applicable if 'parent_slug' is left empty.
        'capability'      => 'manage_options', // Cap required to view options-page.
        'position' => 2 // Menu position. Only applicable if 'parent_slug' is left empty.
    ));
    
    /**
     *  MAIN OPTIONS META - TITLE
     */
    $main_options->add_field(array(
        'id' => $prefix . 'main_options_title',
        'name' => esc_html('General infos', '_themename-site'),
        'type' => 'title'
    ));
    /**
     *  MAIN OPTIONS META - COMPANY NAME
     */
    $main_options->add_field(array(
        'id' => $prefix . 'main_options_company_name',
        'name' => esc_html('Name', '_themename-site'),
        'desc' => esc_html('Insert name', '_themename-site'),
        'type' => 'text'
    ));
    
    [etc...]
    • This reply was modified 5 years, 1 month ago by saxpaolo.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Hmm.

    Using everything except the “[etc…]” i am managing to get the “name” field to fill in, save, and then empty upon save as well.

    That said, I’m also seeing a “Nothing to update.” admin notice, and the theme option is still in place in the database, but just has an empty serialized array.

    Are you seeing different from that?

    Thread Starter saxpaolo

    (@saxpaolo)

    What I see is that it looks like I can update data using everything except an empty field. Also, if I press the save button even without performing any edit to input fields data, I always get an “Settings updated” admin notice.

    (For the sake of information, I’m working on roots/bedrock based environment, while the CMB2 package is installed inside a wppb boilerplate based plugin, included as a mu-plugin)

    • This reply was modified 5 years, 1 month ago by saxpaolo.
    • This reply was modified 5 years, 1 month ago by saxpaolo.
    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    hmm. I wonder if there’s some sort of conflict going on somehow somewhere in your install, since as is I wasn’t able to recreate myself, outside of the weird admin notice when it did succeed for me.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Delete content on text fields’ is closed to new replies.