Custom Field has no standard value of the same ID

Support General Custom Field has no standard value of the same ID

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #48065
    Christian KleeChristian Klee
    Participant

    Hello,

    I used the custom fields to create different event forms. The fields would have user information like user company name from past events prefilled. I created this field with always the same ID like user_company or even the field ID first_name would work to change the user name.

    Now these standard values are not prefilled anymore.
    It still works if I use the PHP Code and add for example rwmb_meta( 'user_company', [ 'object_type' => 'user' ], $current_user_id ) as the std value. But that would require to use always PHP code and modify by hand the standard value.

    New is that I get a waring if I type the same ID:
    This ID already exists in the field group 'User information', please change it or edit that field group to avoid duplication.
    So I guess with this change, my solution stopped working?
    Is there a way to avoid using PHP export every time?

    #48084
    PeterPeter
    Moderator

    Hello Christian,

    Using one field ID for different fields is not a good way. You should have a unique ID per custom field.
    Then if you want to show the last saved field value in a new form as a default value, you can use the PHP code for each field.

    Following the documentation https://docs.metabox.io/field-settings/

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