Skip to content

Commit 17427e8

Browse files
committed
Populate error response with same fields as success response
1 parent 6b93a46 commit 17427e8

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

inc/wplf-form-validation.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/**
44
* Check that Form exists
55
*/
6-
add_filter( 'wplf_validate_submission', 'wplf_validate_form_exists' );
6+
add_filter( 'wplf_validate_submission', 'wplf_validate_form_exists', 1 );
77
function wplf_validate_form_exists( $return ) {
88
// skip this validation if submission has already failed
99
if ( ! $return->ok ) {
@@ -19,14 +19,18 @@ function wplf_validate_form_exists( $return ) {
1919
// translators: %d is form ID
2020
$return->error = sprintf( __( "Form id %d doesn't exist!", 'wp-libre-form' ), intval( $_POST['_form_id'] ) );
2121
}
22+
23+
$p = get_post( $_POST['_form_id'] );
24+
$return->form_id = $p->ID;
25+
$return->slug = $p->post_name;
2226
return $return;
2327
}
2428

2529

2630
/**
2731
* Check for required fields that are empty
2832
*/
29-
add_filter( 'wplf_validate_submission', 'wplf_validate_required_empty' );
33+
add_filter( 'wplf_validate_submission', 'wplf_validate_required_empty', 2 );
3034
function wplf_validate_required_empty( $return ) {
3135
// skip this validation if submission has already failed
3236
if ( ! $return->ok ) {
@@ -64,7 +68,7 @@ function wplf_validate_required_empty( $return ) {
6468
/**
6569
* Check that submission has only fields that are set in form
6670
*/
67-
add_filter( 'wplf_validate_submission', 'wplf_validate_additional_fields' );
71+
add_filter( 'wplf_validate_submission', 'wplf_validate_additional_fields', 3 );
6872
function wplf_validate_additional_fields( $return ) {
6973
// skip this validation if submission has already failed
7074
if ( ! $return->ok ) {

0 commit comments

Comments
 (0)