Custom Fields
Re-Envisioned
Support General Cannot create more fields

  • Creator
    Topic
  • #31920
    Resolved Qu1nt
    Participant

    I am having a issue when I create a new field, it replaces the last field I made, it does not add.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Author
    Replies
  • #31921
    Qu1nt
    Participant

    ok this is getting ridiculous, I deleted the fields and recreated new fields, after inputting all the fields I needed, I saved it and everything disappeared completely blank except the title.

    #31927
    Long Nguyen
    Moderator

    Hi,

    I think there is a special character in a/some field ID. Please create custom fields again, don't publish, and click on the button "Get PHP Code" then share it here. I will help you to check the issue.

    Some screenshots would be appreciated.

    #31947
    Qu1nt
    Participant

    Hi Long,

    Below is the code, I tried recreating this on 2 other sites and the same outcome, it will not let me add or update anything.

    <?php
    add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
    
    function your_prefix_register_meta_boxes( $meta_boxes ) {
        $prefix = '';
    
        $meta_boxes[] = [
            'title'      => __( 'Health History Form', 'your-text-domain' ),
            'id'         => null,
            'post_types' => ['health-form'],
            'fields'     => [
                [
                    'name'   => __( 'PATIENT INFORMATION', 'your-text-domain' ),
                    'id'     => $prefix . 'patient_information',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'name'    => __( 'Last Name', 'your-text-domain' ),
                            'id'      => $prefix . 'last_name',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'First Name', 'your-text-domain' ),
                            'id'      => $prefix . 'first_name',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Date of Birth', 'your-text-domain' ),
                            'id'      => $prefix . 'date_of_birth',
                            'type'    => 'date',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Gender', 'your-text-domain' ),
                            'id'      => $prefix . 'radio_5d2zd5qx8gg',
                            'type'    => 'radio',
                            'options' => [
                                'Male'   => __( 'Male', 'your-text-domain' ),
                                'Female' => __( 'Female', 'your-text-domain' ),
                                'Other'  => __( 'Other', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Address', 'your-text-domain' ),
                            'id'      => $prefix . 'address',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'City', 'your-text-domain' ),
                            'id'      => $prefix . 'city',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Province', 'your-text-domain' ),
                            'id'      => $prefix . 'province',
                            'type'    => 'select',
                            'options' => [
                                'Alberta'                   => __( 'Alberta', 'your-text-domain' ),
                                'British Columbia'          => __( 'British Columbia', 'your-text-domain' ),
                                'Manitoba'                  => __( 'Manitoba', 'your-text-domain' ),
                                'New Brunswick'             => __( 'New Brunswick', 'your-text-domain' ),
                                'Newfoundland and Labrador' => __( 'Newfoundland and Labrador', 'your-text-domain' ),
                                'Northwest Territories'     => __( 'Northwest Territories', 'your-text-domain' ),
                                'Nova Scotia'               => __( 'Nova Scotia', 'your-text-domain' ),
                                'Nunavut'                   => __( 'Nunavut', 'your-text-domain' ),
                                'Ontario'                   => __( 'Ontario', 'your-text-domain' ),
                                'Prince Edward Island'      => __( 'Prince Edward Island', 'your-text-domain' ),
                                'Quebec'                    => __( 'Quebec', 'your-text-domain' ),
                                'Saskatchewan'              => __( 'Saskatchewan', 'your-text-domain' ),
                                'Yukon'                     => __( 'Yukon', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Postal Code', 'your-text-domain' ),
                            'id'      => $prefix . 'postal_code',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Home Phone', 'your-text-domain' ),
                            'id'      => $prefix . 'home_phone',
                            'type'    => 'tel',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Cell Phone', 'your-text-domain' ),
                            'id'      => $prefix . 'cell_phone',
                            'type'    => 'tel',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Work Phone', 'your-text-domain' ),
                            'id'      => $prefix . 'work_phone',
                            'type'    => 'tel',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Email', 'your-text-domain' ),
                            'id'      => $prefix . 'email',
                            'type'    => 'email',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Occupation', 'your-text-domain' ),
                            'id'      => $prefix . 'occupation',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'type' => 'divider',
                        ],
                        [
                            'name'    => __( 'Primary Care Physician\'s Name', 'your-text-domain' ),
                            'id'      => $prefix . 'primary_care_physician\'s_name',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Phone Number', 'your-text-domain' ),
                            'id'      => $prefix . 'phone_number',
                            'type'    => 'tel',
                            'columns' => 3,
                        ],
                        [
                            'type' => 'divider',
                        ],
                        [
                            'name'    => __( 'Did a healthcare practitioner refer you for therapy?', 'your-text-domain' ),
                            'id'      => $prefix . 'did_a_healthcare_practitioner_refer_you_for_therapy',
                            'type'    => 'radio',
                            'options' => [
                                'Yes' => __( 'Yes', 'your-text-domain' ),
                                'No'  => __( 'No', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Practitioner\'s Name', 'your-text-domain' ),
                            'id'      => $prefix . 'practitioner\'s_name',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Practitioner\'s Phone Number', 'your-text-domain' ),
                            'id'      => $prefix . 'practitioner\'s_phone_number',
                            'type'    => 'tel',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Have you received therapy before?', 'your-text-domain' ),
                            'id'      => $prefix . 'have_you_received_therapy_before',
                            'type'    => 'radio',
                            'options' => [
                                'Yes' => __( 'Yes', 'your-text-domain' ),
                                'No'  => __( 'No', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                    ],
                ],
                [
                    'type' => 'divider',
                ],
                [
                    'type' => 'divider',
                ],
                [
                    'name'   => __( 'INJURY INFORMATION', 'your-text-domain' ),
                    'id'     => $prefix . 'injury_information',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'type' => 'divider',
                        ],
                        [
                            'name'    => __( 'What is the reason you are seeking therapy?', 'your-text-domain' ),
                            'id'      => $prefix . 'what_is_the_reason_you_are_seeking_therapy',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Are you currently seeing another healthcare professional regarding this condition?', 'your-text-domain' ),
                            'id'      => $prefix . 'are_you_currently_seeing_another_healthcare_professional_regarding_this_condition',
                            'type'    => 'radio',
                            'options' => [
                                'Yes' => __( 'Yes', 'your-text-domain' ),
                                'No'  => __( 'No', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Please indicate the location of any tissue or joint discomfort', 'your-text-domain' ),
                            'id'      => $prefix . 'please_indicate_the_location_of_any_tissue_or_joint_discomfort',
                            'type'    => 'textarea',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Please indicate all the symptoms you\'re currently experiencing', 'your-text-domain' ),
                            'id'      => $prefix . 'please_indicate_all_the_symptoms_you\'re_currently_experiencing',
                            'type'    => 'checkbox_list',
                            'options' => [
                                'Numbness'                   => __( 'Numbness', 'your-text-domain' ),
                                'Tingling'                   => __( 'Tingling', 'your-text-domain' ),
                                'Pins & Needles'             => __( 'Pins & Needles', 'your-text-domain' ),
                                'Stiffness'                  => __( 'Stiffness', 'your-text-domain' ),
                                'Soreness'                   => __( 'Soreness', 'your-text-domain' ),
                                'Aching Pain'                => __( 'Aching Pain', 'your-text-domain' ),
                                'Dull Pain'                  => __( 'Dull Pain', 'your-text-domain' ),
                                'Burning Pain'               => __( 'Burning Pain', 'your-text-domain' ),
                                'Throbbing Pain'             => __( 'Throbbing Pain', 'your-text-domain' ),
                                'Sharp and/or Shooting Pain' => __( 'Sharp and/or Shooting Pain', 'your-text-domain' ),
                            ],
                            'inline'  => true,
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'On a scale from 0-10, please rate your current level of pain', 'your-text-domain' ),
                            'id'      => $prefix . 'on_a_scale_from_0-10_please_rate_your_current_level_of_pain',
                            'type'    => 'radio',
                            'options' => [
                                __( '0', 'your-text-domain' ),
                                __( '1', 'your-text-domain' ),
                                __( '2', 'your-text-domain' ),
                                __( '3', 'your-text-domain' ),
                                __( '4', 'your-text-domain' ),
                                __( '5', 'your-text-domain' ),
                                __( '6', 'your-text-domain' ),
                                __( '7', 'your-text-domain' ),
                                __( '8', 'your-text-domain' ),
                                __( '9', 'your-text-domain' ),
                                __( '10', 'your-text-domain' ),
                            ],
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'What makes the pain worse?', 'your-text-domain' ),
                            'id'      => $prefix . 'what_makes_the_pain_worse',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'What makes the pain better?', 'your-text-domain' ),
                            'id'      => $prefix . 'what_makes_the_pain_better',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Injury date if known', 'your-text-domain' ),
                            'id'      => $prefix . 'injury_date_if_known',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                        [
                            'name'    => __( 'Surgery date if any', 'your-text-domain' ),
                            'id'      => $prefix . 'surgery_date_if_any',
                            'type'    => 'text',
                            'columns' => 3,
                        ],
                    ],
                ],
                [
                    'type' => 'divider',
                ],
                [
                    'type' => 'divider',
                ],
                [
                    'name'   => __( 'MEDICAL INFORMATION', 'your-text-domain' ),
                    'id'     => $prefix . 'medical_information',
                    'type'   => 'group',
                    'fields' => [
                        [
                            'type' => 'heading',
                            'name' => __( 'Please indicate conditions you are currently experiencing or have experienced in the past:', 'your-text-domain' ),
                        ],
                    ],
                ],
            ],
        ];
    
        return $meta_boxes;
    }
    #31957
    Long Nguyen
    Moderator

    Hi,

    Please remove all the single quotes (or any special characters) from the field IDs and re-check this issue. For example:

    primary_care_physician's_name

    it should be

    primary_care_physicians_name

    Follow our recommendation about field ID:

    Field ID. Required and must be unique. It will be used as meta_key when saving to the database. Use only numbers, letters, and underscores (and rarely dashes).
    https://docs.metabox.io/field-settings/#general

    #31965
    Qu1nt
    Participant

    Hi,

    I removed all special characters, same result, I cannot add any more fields or edit anything including the post type.

    #31981
    Long Nguyen
    Moderator

    Hi,

    It's so weird. Please try to deactivate all plugins except Meta Box, MB AIO, switch to the standard theme of WordPress (Twenty TwentyOne), and re-check this issue.

    You can also follow this article to increase the PHP setting max_input_vars
    https://metabox.io/wordpress-custom-fields-not-saving-increase-max-input-vars/

    Let me know how it goes.

    #31986
    Qu1nt
    Participant

    Hi Long,

    that was it, I increased from 5000 to 10000 now it seems to be working fine.

    Thank you very much for your help.

    Quint

Viewing 7 replies - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.