Support

Account

Home Forums Backend Issues (wp-admin) Issue on creating a new multiple select field type Reply To: Issue on creating a new multiple select field type

  • Thank you for your reply, tgillet1. I had forgotten this post until I received a notification email. In fact, I already solved this issue myself and realized I misunderstood about the field.

    As you said, the field box with a number-field-like appearance was just a multi-select field with size=”1″. I jumped to the wrong conclusion.

    By the way, I’d like to write down my findings here for future reference.

    [1] Of the above code, $field[‘ajax’] = 1 was not necessary. On the contrary, it causes blank field when used with $field[‘ui’] = 1 (unless ajax actions are properly set).

    [2] Even when $field[‘ui’] is set to 1, the appearance of the field still not be ‘Stylized UI’. For example, here is the code and rendered field images.

    
    function render_field( $field ) {
      $field['type'] = 'select';
      $field['ui'] = 1; // or 0
      $field['multiple'] = 1; // or 0
      $field['choices'] = array(
        101 => 'Choice-1',
        102 => 'Choice-2',
        103 => 'Choice-3',
      );
      acf_render_field( $field );
    }
    

    Since I couldn’t solve this problem, I took an alternative approach.

    [3] Referring to other ACF plugins, I solved the issue by using the prepare_field function instead of the render_field function. Here is the URL of the plugin I created.
    https://github.com/game-ryo/ACF-Multiple-Taxonomy-Field