

mmmh as soon as i want to save the post with the new values i get this notice:
PHP Notice: Trying to get property of non-object in /Users/nicb/Data/_htdocs/testnow/wp/wp-includes/post-template.php on line 29
PHP Notice: Trying to get property of non-object in /Users/nicb/Data/_htdocs/testnow/wp/wp-content/themes/bootstrap/functions.php on line 527
line 527 if from that function:
‘post_id’ => $assignedpost->ID
but it saves me the post. whats wrong with it?

alright. my fault!
this is correct:
if( is_array($comments) )
{
foreach( $comments as $key=>$comment )
{
$field['choices'][ $comment->comment_ID ] = $comment->comment_content;
}
}
but what is default_value then??
thank you very much elliot. i love your plugin!!

nice one elliot! this leads me to the right direction. but i think i found a bug?! i am using ACF 5.0.3.
this is my function:
/* auto populate acf field with comment IDs */
function my_acf_load_field( $field ){
$assignedpost = get_field('produktblog');
$comments = get_comments(array(
'status' => 'approve',
'post_id' => $assignedpost->ID
));
if( is_array($comments) )
{
foreach( $comments as $key=>$comment )
{
$field['choices'][ $key ] = $comment->comment_content;
$field['default_value'][ $key ] = $comment->comment_ID;
}
}
return $field;
}
// v4.0.0 and above
add_filter('acf/load_field/name=kommentare', 'my_acf_load_field');
and this is the print_r from $field:
Array
(
[ID] => 150
[key] => field_53e327ee805e6
[label] => Kommentare
[name] => kommentare
[prefix] =>
[type] => select
[value] =>
[menu_order] => 0
[instructions] =>
[required] => 0
[id] =>
[class] =>
[conditional_logic] => 0
[parent] => 6
[_name] => kommentare
[_input] =>
[_valid] => 1
[choices] => Array
(
[0] => kommentar3
[1] => kommentar2
[2] => kommentar1
)
[default_value] => Array
(
[0] => 7
[1] => 6
[2] => 5
)
[allow_null] => 1
[multiple] => 1
[ui] => 0
[ajax] => 0
[placeholder] =>
[disabled] => 0
[readonly] => 0
)
the select field accepts the choices but not the values:
https://www.dropbox.com/s/h4ek9agt4wk97vg/Screenshot%202014-08-07%2009.47.48.png
so as you can see, the value is still 0,1,2. but it has to be 7,6,5

same question asked in old forum: http://old.support.advancedcustomfields.com/discussion/6151/feature-request-direct-drag039n039drop
and now its time to ask again :D. are there any news about that? also would love to see a way to write title and alt text direct in list view instead of opening each image.
thanks!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.