Support

Account

Home Forums General Issues Repeater field + Auto populate select

Solved

Repeater field + Auto populate select

    • Bobz

    • August 15, 2013 at 3:24 am

    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

    • Elliot

    • August 15, 2013 at 2:20 pm

    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?

    • Bobz

    • August 15, 2013 at 5:16 pm

    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

    • Elliot

    • August 16, 2013 at 1:09 pm

    Hi @bobz

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

    Thanks
    E

    • Bobz

    • August 22, 2013 at 2:00 am

    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.

    • Bobz

    • August 24, 2013 at 2:58 am

    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?

    • Elliot

    • August 25, 2013 at 4:19 pm

    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)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.