it is not written, I agree, but to me clarifying how it works will help a lot.
As normally getting a FALSE from an API is managed as an error.
My 2 cents.
π
Hi the problem is that the documentation says that update_field() return TRUE if all ok, FALSE in case of failure.
Instead is also returning FALSE if the value is not updated (because the value you pass to the function is the same with the current DB value).
It should be CLEAR that the function return FALSE not only in case of failure.
(and I agree that the problem is also at WP level).
This because if you write a code like this:
if(!update_field(…)) handle_error(…);
you get crazy (because in some case there is no error to handle !)
Hi thanks for your Answer
What i should put as parent menΓΉ slug considering the parent is an ACF option page (admin.php?pAge=myoptions Does not. Work)
Angelo
yes I have the same problem: I have existing post meta attributes, and I would like that this attrs are ‘recognized’ in ACF (I am using ACF PRO 5.2.3).
So a part creating the field in ACF, what we should do to have existing values recognized? (I guess what is missing are the _fieldkey_xxxx rows in postmeta table).
Hi Elliot,
yes but this is logically incorrect: if I have a boolean field, the possible values are TRUE and FALSE.
So once the user is prompted to fill a form, a checkbox unticket is representing a FALSE value, so it’s NOT empty.
Imagine the case where a field is ‘Do you want a newsletter?’ so it means that the checkbox must be checked always? π
Cheers
PS: peraphs I tried to unset the required attribute (to let my form works) but due to a bug on 5.2.4 (not ablet to save/update large field group) I reverted back to 5.2.3 (I see today a 5.2.5 version is available that fix this bug).
Get to work with this:
$field = get_field_object($field_key);
echo $field[‘choices’][‘fr’];
A question: are the field key ‘stable’. i.e., they are created/associated when a field is created and then the never changes?
There is way to get the field key from the field name? I would like not to write specifically field keys in the source code….
Yes this I think can work. I was looking for some action from ACF instead is correct you use ‘save_post’ action of WP. So once the post is saved, ACF get_field() function will work !
Thanks π
Angelo
Hi thank you for the suggestion.
The issue is that on the php side while I’am saving the new value I need to get the values of other ACF fields, something like
$total = get_field(‘price’) * get_field(‘qty’);
update_field(‘total’, $total);
BUT the issue is that I cannot use get_field(‘xxxx’) as the field xxx is not yet saved in the DB (as is a new post).
Thanks…in fact my main concer is about stability, as this is a new (very) major release.
So Elliot if you confirm this I will go for ACF PRO.
Thanks
Angelo
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.