I stepped through the code and found an easier way. First parameter I believe can be the group slug string or ID. Didn’t get to the bottom of what was causing the infinite loop.
$group_fields = acf_get_raw_fields('group_5a18e8e4866e0');
+1 please add 🙂
+1, would like this feature.
I implemented this JS referencing the JS API.
acf.add_filter('time_picker_args', function (args, field) {
args.timeFormat = 'h:mm'
args.altTimeFormat = 'HH:mm'
args.stepMinute = 15
return args;
});
Looks like there’s been an update because now you can just do this. I took this from their API documentation page. You can change the selectors in this to do whatever you want, the code below will fire two events, one for all inputs on change the other specifically for text input types.
var instance = new acf.Model({
events: {
'change': 'onChange',
'change input[type="text"]': 'onChangeText',
},
onChange: function(e, $el){
e.preventDefault();
var val = $el.val();
// do something
},
onChangeText: function(e, $el){
// do something for just text inputs and then call the normal change callback
this.onChange(e, $el);
}
});
This snippet is important if you want to utilize the default image value in the front end.
add_filter('acf/load_value/type=image', 'reset_default_image', 10, 3);
function reset_default_image($value, $post_id, $field) {
if (!$value) {
$value = $field['default_value'];
}
return $value;
}
It almost works but because he is missing the “not” operator it fails to add the first entry. Here is the pseudo code.
$gallery_array = get_field($key, $post_id, false);
if (!is_array($gallery_array )) {
$gallery_array = array();
}
$gallery_array [] = $img_attachment_id;
update_field($key, $gallery_array , $post_id);
Set the display format to “H:i” by selecting the custom radio button option. Only issue I found with this is that it saves the time to the database with seconds so I used this hook to remove the seconds when it saves it.
add_filter( 'acf/update_value/type=time_picker', 'acf_update_date_time_picker_value', 10, 3 );
function acf_update_date_time_picker_value( $value, $post_id, $field ) {
return date('Y-m-d H:i',strtotime($value));
}
Set the display format to “H:i” by selecting the custom radio button option. Only issue I found with this is that it saves the time to the database with seconds so I used this hook to remove the seconds when it saves it.
add_filter( 'acf/update_value/type=time_picker', 'acf_update_date_time_picker_value', 10, 3 );
function acf_update_date_time_picker_value( $value, $post_id, $field ) {
return date('Y-m-d H:i',strtotime($value));
}
I moved the function acf_form_head() above the themes function get_header() and now it seems to work.
Cheers.
@elliot any updates mate? 🙂
Ok @elliot , I’ve uploaded the site. Create yourself an account, ADD A TRADE and then try and edit it.
http://tradelaide.com.au/register/
After adding a trade you can view your trades here
http://tradelaide.com.au/view-trades/
Let me know how you go.
Cheers
Yes that’s correct Elliot! Ok, good idea, I’ll do that tonight. Thanks very much for your assistance it’s greatly aprpeciated 🙂
Ok I deactivated all plugins except ACF, used Twenty Sixteen theme and it still doesn’t hide my field…
Any other suggestions? I’m on the latest version of ACF 5.4.4 and latest WordPress version 4.6.1.
I’m testing the site locally on a WAMPSERVER instance.
Sure, I’ll give that a go. The console is not showing any errors so I’ll activate and deactivate some plugins.
Cheers.
Here’s my export. It fails for me when I toggle the combobox for field called “Type” it should toggle the field called “Trade Accepted” when I am editing the post. New posts work fine, it toggles the field on/off.
Cheers.
I think it actually defaults to the basic uploader if you don’t have permissions. However, the gallery field is the control that does not work.
Has this been resolved, I am experiencing a similar issue with conditional logic on a combobox. When I select a particular value it doesn’t remove a textbox lower down on the form. However, when adding a new post this conditional logic works.
I worked out what the issue was. This is related to the following closed issue.
Basically, users need to have a minimum of an Author role in order to upload media files otherwise you get that non-descriptive error in the console as follows.
Uncaught TypeError: Cannot read property 'query' of undefined
Yes what StevieC said. Users need to have a minimum of an Author role in order to upload media files otherwise you get that non-descriptive error,
Cheers, I have closed it.
That thread you linked was not created by me. So which thread do you want closed?
It seems that way. I sent a login to one of the other support stuff on PM to see if he can replicate the issue. Do you want one also?
This is still an issue. I opened up a private thread with James but I have no idea how to respond to him now…
I’m still having issues with this.
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.