Custom Fields
Re-Envisioned
Support General Proper way to clone a custom field

This topic contains 2 replies, has 2 voices, and was last updated by  Bruno Faúndez Valenzuela 4 weeks ago.

  • Creator
    Topic
  • #14999
    Resolved
    Bruno Faúndez Valenzuela
    Participant

    Hi. I created a Custom Field Type to add service IDs to Hotels (which is a CPT). I defined the field type as: tb-service-id. Then I add this field to the corresponding metabox. I’ve set:

    'clone' => true

    and the button to clone the field appears, but the field is generated with the same ID as the other one:

    _hotel_tb_service_id[0]

    In the html mehod of the Custom Field Type I create a select and set the ID to the variable: $field[‘id’] which gives the value: ‘_hotel_tb_service_id[0]’.

    Any help would be much appreciated

Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
    Replies
  • #15009

    Anh Tran
    Keymaster

    Hi Bruno,

    Please try to set a custom CSS class for the inputs which starts with rwmb. See here to understand how the clone works.

    #15032

    Thank you so much! It worked perfectly!
    It would be good to see a comment about the relation of the css class and the “cloneability” of the field in the documentation of the RWMB_Field Class.

    Have a great day 🙂

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

You must be logged in to reply to this topic.