yes javascript console
I can also confirm this .. when I role back to ACF 5.7.7 the problem goes away
An invalid form control with name='' is not focusable
Wordpress 5
Classic Editor installed
i’m having this issue too .. how did you solve it?
thanks .. will do
thanks . .yeah i’m doing something like that .. but it’s not very intuitive .. seems like it could make it easier for everyone if a reference to $field was just passed through
i’m trying to add a class to the ‘body_class’ setting of the tinymce editor before it gets initialized … i need to be able to add custom styles to different WYSIWYG ACF fields and the moment there is no way to differentiate them if there is more than one on a page
by including the $field i could then add a field specific class to each editor instance
boom! nice find
thank you
maybe switch my feature request to update the documentation page for the Clone field with this tip
I think you could use the ‘acf/get_fields’ filter to change the order before they get rendered
This works for me
add_action('acf/save_post', 'custom_acf_save_post', 20);
function custom_acf_save_post( $post_id ) {
// bail early if no ACF data
if( empty($_POST['acf']) ) {
return;
}
$data['ID'] = $post_id;
// Combine first name and last name to create a title
$title = trim($_POST['acf']['field_55687a737d49f']) . " " . trim($_POST['acf']['field_55687a917d4a0']);
$data['post_title'] = $title;
$data['post_name'] = sanitize_title( $title );
wp_update_post( $data );
}
yes the null trick didn’t work for me either
in fields/radio.php I’m seeing this bit of code at line 114-119
// select first choice if value is not a valid choice
if( !isset($field['choices'][ $field['value'] ]) ) {
$field['value'] = key($field['choices']);
}
This seems to be where the first option is set by default – can anyone tell me why there might be a good reason to NOT delete these lines (other than editing core plugin files). What purpose does this bit of code have?
Any more thoughts on this .. would LOVE to be able to do this.
I think the function you are looking for is ‘acf_get_post_types’ and it does not appear to be filterable. Look in api-helpers.php
I would also like to be able to do this.
Elliot, any chance of adding a filter into this function?
cool thanks, i’ll add that in!
ok here are my core hack updates to allow for wrapping of field groups and optional display of field group titles in front end forms
usage:
$args = array(
wrap_field_groups' => false // don't wrap [default]
wrap_field_groups' => true // wrap without title
wrap_field_groups' => 'show_title' // wrap with title
);
acf_form($args);
api-field.php
line 474 – 480
// ACF5 core hack BEGIN
// are we opening or closing a field group?
if( $field['field_group_wrap'] === true ) {
echo $field['value'];
return;
}
// ACF5 core hack END
api-template.php
line 1273 – 1275
// ACF5 core hack BEGIN
'wrap_field_groups' => false,
// ACF5 core hack END
line 1386 – 1401
// ACF5 core hack BEGIN
// check for field group wrap
if( !empty( $args['wrap_field_groups'] ) ){
$wrapper = array(
'field_group_wrap' => true,
'value' => '<div id="'.$field_group['key'].'" class="acf_form_field_group_wrap">'
);
if ( 'show_title' === $args['wrap_field_groups']) {
$wrapper['value'] = '<div id="'.$field_group['key'].'" class="acf_postbox acf_form_field_group_wrap">
<h3 class="acf_form_field_group_title">'.$field_group['title'].'</h3>';
}
$fields[] = $wrapper;
}
// ACF5 core hack END
line 1408 – 1416
// ACF5 core hack BEGIN
// check for field group wrap
if( !empty( $args['wrap_field_groups'] ) ){
$fields[] = array(
'field_group_wrap' => true,
'value' => '</div><!-- end field group -->'
);
}
// ACF5 core hack END
cool thanks .. if I make any additional enhancements to what you posted here i’ll share them on this thread
It would also be ideal if there was another parameter in acf_form that let you toggle display of the field group name as well – this would kind of emulate how the “style” option works for field groups in the backend .. ie Standard (WP Metabox) with field group title or Seamless (no metabox) and no field group title
+1 this is great, thanks
did you ever get any response about integrating your ideas into the plugin core?
in ACF4 field groups were wrapped which allowed for much more flexibility in the visual display of front end forms
I did some testing and it looks like in the upgrade from 4 to 5 any Field Groups (post_type==acf) are kind of cloned into a new post with post_type==acf-field-group
As I said in my original post I have a custom solution that involves storing the post IDs of field groups in a custom field. If I upgrade the project from 4 to 5 (which I’d really like to do) then the post IDs I have stored will still reflect the ACF4 ‘acf’ posts and not the ACF5 ‘acf-field-group’ posts.
During upgrade is there any reference made that links the ACF4 post ID to its upgraded ACF5 post ID? If so then I could write a query that would go through and update all of the post IDs.
OR
Is it possible to hook into the upgrade and update my post IDs then?
thanks!
not sure – i haven’t tested this on version 5 yet
try this way
<script type="text/javascript">
jQuery(function($){
/** your code **/
});
</script>
in your example it would look like this – but i think it will fire on every field in your form so you’d want to select for the specific field you want to validate:
jQuery(document).on('acf/validate_field', function( e, field ){
var $field = jQuery(field);
$field.data('validation', false);
});
have you confirmed your .js file is definitely being enqueued and is in the correct location?
I’d be happy to keep contributing to this .. I’m using it in its current form (along with the changes I’ve posted above) but there are still a couple of wonky things about it that I’d love to get cleaned up
I’m not aware of a codebase for this on Github
@Sarah
i added it from a custom plugin like this:
add_action( 'wp_enqueue_scripts', 'my_enqueue_styles_scripts' );
function my_enqueue_styles_scripts() {
wp_enqueue_script( 'acf-custom-validation', plugins_url( 'inc/js/acf-custom-validation.js', __FILE__ ), array( 'acf-input' ) );
}
thanks .. i used
wp_get_attachment_image_src( $image['id'], 'full' );
but this is definitely more concise – thanks
$image['url']
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.