Support

Account

Home Forums Backend Issues (wp-admin) New field type: select Reply To: New field type: select

  • So I’ve managed to store my select field’s value, by passing it to a hidden input field, which works fine. But now I’m facing some trouble with the repeater field.

    ACF generates a repeater’s subfield $field[‘name’] and $field[‘ID’], by replacing [acfcloneindex] by an $i integer value, through the use of javascript–see this post for reference.
    I haven’t found a way to get around the [acfcloneindex] riddle yet, but I’m wondering how ACF stores its own select fields values.

    I’m generating the select code of my field using the same structure as ACF, but ACF won’t store the value upon saving the post:

    echo '<select id="' . esc_attr($field['id']) . '" name="' . esc_attr($field['name']) .'" data-ui="0" data-ajax="0" data-multiple="0" data-placeholder="Select" data-allow_null="0">';
    $output .= '<option value="0"></option>';
    foreach($options as $option){
    ...
    }
    echo $output . '</select>';

    So the question is, what am I missing? How can I store my select field’s value?

    I figure there has to be a better way than by using hidden inputs, right?