• Resolved Suraj Gupta

    (@surajgupta25)


    After rendering a field using cmb2_get_field (date picker in this case)
    I think the related js for the date picker isn’t added and when I am clicking on the field, then date picker isn’t appearing.

    Here’s the code I’m using –

    $cmb_box_sync_post_form = new_cmb2_box(array(
                'id' => 'ccb_event_sync_to_post_metabox',
                'hookup' => false,
                'save_fields' => false,
                'cmb_styles' => false,
            ));
            $cmb_box_sync_post_form->add_field(array(
                'name' => __('Fetch Events Start Date', 'liquid-outreach'),
                'desc' => __('',
                    'liquid-outreach'),
                'id' => 'start_date', // No prefix needed.
                'type' => 'text_date',
                'default' => !empty($_POST['start_date']) ? $_POST['start_date'] : '',
                'attributes' => [
                    'required' => 'required'
                ]
            ));
            $cmb_box_sync_post_form->add_field(array(
                'name' => __('Fetch Events End Date', 'liquid-outreach'),
                'desc' => __('',
                    'liquid-outreach'),
                'id' => 'end_date', // No prefix needed.
                'type' => 'text_date',
                'default' => !empty($_POST['end_date']) ? $_POST['end_date'] : '',
                'attributes' => [
                    'required' => 'required'
                ]
            ));
    $cmb_field_start_date = cmb2_get_field('ccb_event_sync_to_post_metabox', 'start_date');
                    $cmb_field_start_date->render_field();
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Contributor Michael Beckwith

    (@tw2113)

    The BenchPresser

    Just to rule it out as a possibility, have you checked your browser’s developer console to see if possibly some javascript errors are appearing that would be preventing the datepicker from showing?

    Thread Starter Suraj Gupta

    (@surajgupta25)

    Yes, there are no errors in console.

    Plugin Author Justin Sternberg

    (@jtsternberg)

    Yes, you’re loading a field outside of a cmb2 box context, so certain hooks won’t take place. What are you doing that you don’t need the entire form?

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

The topic ‘Issue after rendering a field using cmb2_get_field’ is closed to new replies.