• Resolved vrhovc

    (@vrhovc)


    I am trying to get a front-end form, i have adopted this code for my case:
    https://github.com/WebDevStudios/CMB2-Snippet-Library/blob/master/front-end/cmb2-metabox-shortcode.php

    I have some fields that have ‘on_front’ => false parameter set and for those fields the values saved before are cleared.

    How to fix that the NOT used fields on the front get preserved?

    $cmb->add_field( array(
            'name' => __( 'Owner ID', 'theme-domain' ),
            'desc' => __( 'Numbers only', 'msft-newscenter' ),
            'id'   => $prefix . 'owner_id',
            'type' => 'text',
            'on_front'        => false, // Optionally designate a field to wp-admin only
            'attributes' => array(
                'type' => 'number',
                'pattern' => '\d*',
            ),
        ) );

    I will set this field in admin or will write a function to automaticaly set it for me, but the main thing is that is hidden from user using the form

    And the other question:
    I have custom post type that uses WPs title, editor and thunbnail, how to get them to the front-end form, or is it better to create my custom fields in CMB2, that have the same purpose?

    I am new to CMB2 so I guess there be a lot more questions to come.

    https://wordpress.org/plugins/cmb2/

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

    (@tw2113)

    The BenchPresser

    trying to make sense of the first question.

    It sounds like you have a mix of sources for where information will come from. Some will be set via the frontend form, some will be set via the admin. If I’m reading right, you’re also sort of mixing when which fields are shown while keeping them all together?

    I would look over https://github.com/WebDevStudios/CMB2/wiki/Field-Types and https://github.com/WebDevStudios/CMB2/wiki/ in general.

    You’ll see that you can set default values for fields, which may help in what you’re trying to accomplish here.

    Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    For the second question, not sure how best to handle that one, as those are different areas in the database than the postmeta table which CMB2 works with.

    Perhaps a better sense of what you’re trying to achieve overall at the moment would help give a better picture for me to work from.

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

The topic ‘Front-end edit form’ is closed to new replies.