Home Forums General Issues Frontend form – post via ajax? Reply To: Frontend form – post via ajax?

  • Hi @phylaxis,

    I have a custom validation message save in custom field settings.
    It’s maybe not the best solution but it’s works fine for me!

    add_action('acf/render_field_settings', '_pit_add_field_setting_for_error_message');
    function _pit_add_field_setting_for_error_message( $field ) {
        $args = array(
            'type' => 'text',
            'label' => 'Erreur formulaire',
            'name' => 'error_form',
            'instructions'	=> 'Erreur affiché a l\'utilisateur lors du remplissage du formulaire',
            'required' => 0,
            'default_value' => "Veuillez remplir ce champ"
        acf_render_field_setting($field, $args, false);
    add_filter('acf/validate_value', '_pit_acf_form_error_message', 10, 4);
    function _pit_acf_form_error_message( $valid, $value, $field, $input ){
            $valid = $field['error_form'];
        return $valid;

    The first hook set the field and the second one print the error if the field is not valid. It’s works for me in AJAX form. I hope this code will help you. If you have a best way to to it I’m more than interrested!

    I have try to set the field only when is required but it was a fail for me.. It’s works only when the field is save one time.

    Sorry @pooledge I have try with the basic uploader and it’s doesn’t works for me too.

    Thanks! 😉