Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show success/error messages in-page (as opposed to in-widget) #8

Open
marks opened this issue Aug 17, 2014 · 1 comment
Open

Show success/error messages in-page (as opposed to in-widget) #8

marks opened this issue Aug 17, 2014 · 1 comment

Comments

@marks
Copy link

marks commented Aug 17, 2014

Is this even possible?

@zackkatz
Copy link
Member

You can get the errors using the following code:

if( class_exists('CTCT_Process_Form') ) { 
$errors = CTCT_Process_Form::getInstance()->getErrors();
}

Then you can loop through the returned errors array, which is an array of WP_Error objects:

$error_output = '';
foreach ($errors as $error ) {

/**
 * The input ID is stored in the WP_Error error data.
 * @see CTCT_Process_Form::checkRequired()
 */
$error_field_id = CTCT_Form_Designer_Output::get_field_id( $ProcessForm->id(), $error->get_error_data() );

$error_label_for = ' for="'.esc_attr( $error_field_id ).'"';

$error_output .= '<div><label'.$error_label_for.'>'.$error->get_error_message().'</label></div>';
}

There's not a non-codey way to do this yet, but I think it's a good idea.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants