Custom Fields
Support General Proper way to clone a custom field

  • Creator
  • #14999
    Resolved Bruno Faúndez Valenzuela

    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:


    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 3 replies - 1 through 3 (of 3 total)
  • Author
  • #15009
    Anh Tran

    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.


    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 🙂


    Hi. I'm getting some weird behaviour related to this. My custom field has some selects that are used to filter asyncronously a list with the option for the field. The custom field looks like this:

    [Service Type]
    [Service Region]

    All of those three inputs are selects but only the last one is the value that should be stored. It's wrapped as a vue.js app and when you select one of the [Service Type] or [Service Region] options, the [Service] select is populated with data.

    The [Service] select has the class rwmb-vueselect so it can be detected by the plugin.

    With a single input it works well, but when I clone it, the data of the first input stores the [Service Region] selection of the second field and the second field stores it's proper data from its [Service]. Is there any way to explicitly say which fields should be stored?

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