Hi E,
I have one more question pls, here is my js code: http://pastebin.com/hejnDsgg
What I do here is:
1. I have 3 different post types where I want to use this auto populate
2. Every post type has different id for select menu, so I have put their id into variables to make life easier
3. I get selected value from ‘Select Country’
4. I do AJAX to get list of areas and cities for that country
5. I get response as comma seperated (eg: city1,city2,city3)
6. I do with jquery each:
$( '#' + selector_area ).append( $('<option></option>').val(text).html(text) )
This is how I append values as options under my select menu.
Now everything here works fine, but problem is that saved value is not selected or displayed.
Every time I refresh ‘Edit posts’ area is not correct so I need to select area every time I edit and save post.
Any advice please?
BR
V
Hi,
I’m not quite sure how to do this correct.
– I have function that returns me list of Areas: http://pastebin.com/Y0Z1YPwQ
Function accepts 1 param (Selected country) and that param is passed via ajax, so function returns me array of areas
– Can I somehow now call ‘acf/load_field/’ filter or should I use jquery to populate ‘Areas’ select field?
Thanks in advanced
BR
V
Ok, thanks I will try to figure out something.
BR
V
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,
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 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
Ok, thanks will check it out.
For now I have found my way
Cheers
Hi,
This helps but I don’t see a value user selected, only field info.
Or am I doing something wrong?
Hi,
I have added my custom CSS for now, and it looks better: http://imgur.com/qx6Gw5e and it’s more user friendly.
I think 33% option would do fine.
BR
Vlado
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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.