Support

Account

Home Forums General Issues Repeater field + Auto populate select

Solved

Repeater field + Auto populate select

  • Hi,

    Maybe it’s out of scope of support, but I will ask anyway 🙂
    I have this: http://pastebin.com/9x9vftgi

    It’s option page where you can add

    1. Country
    1.1. Cities (name)
    2.2. Areas (name + image)

    Everything is repeatable 🙂

    So what I’m trying to achieve is

    When user selects country, he then gets 2 select fields
    1. Select Nearest City
    2. Select Area

    And I want to populate these select boxes with data from selected country only.
    Here is screenshot of the field in admin: http://i.imgur.com/4SfF02c.jpg

    Would appreciate if you could point me somewhere, because i’m stuck.

    BR
    Vlado

  • Hi @bobz

    Thanks for the question.

    Yes, it is possible, but it will not be easy.

    May I ask where it is that the user will select the country? Is this somewhere on the front end of the website?

  • Hi elliot,

    Everything is on backend, I have this custom post types with 30 custom fields.
    If it’s to complicated I will remove city from it and make it input field, then i would have only Country and Area.
    I always try to make more user friendly but then I put myself in trouble 😛

    BR
    Vlado

  • Hi @bobz

    Can you please be more clear. What post types?
    How do ’30 custom fields’ relate to this question?

    Thanks
    E

  • Hi,

    Sorry for late reply.
    I’m kind of to busy to think on anything else.

    Anyway I have simplified things a little bit I will create special page for areas and special for cities.

  • Hi,

    I’m not able to make this work.
    I have added:

    function my_acf_load_field2( $field )
    {
        $field['choices'] = array(
            'custom' => 'My Custom Choice'
        );
     
        return $field;
    }
     
     
    // acf_load_field-{$field_key} - filter for a specific field based on it's key
    add_filter('acf_load_field-field_520fa5c4c3ce6', 'my_acf_load_field2');

    to my functions.php, but it doesn’t work.
    I’m trying to populate select field:

    <select id="acf-field-reserve_country" class="select" name="fields[field_520fa5c4c3ce6]">

    I use ACF as a plugin.
    Doing something wrong?

  • Hi @bobz

    If you are using ACF v4 or above, you will need to change the filter name to this:
    http://www.advancedcustomfields.com/resources/filters/acfload_field/

    acf/load_field/key=field_520fa5c4c3ce6

Viewing 7 posts - 1 through 7 (of 7 total)

The topic ‘Repeater field + Auto populate select’ is closed to new replies.