Last active
September 11, 2015 08:05
-
-
Save mzur/f3f1ff18ff8b4ad87fbb to your computer and use it in GitHub Desktop.
Old version of the AJAX response template (http://blog.the-inspired-ones.de/ajax-uniform)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header::contentType('application/json'); | |
$errors = ''; | |
// check each parameter of the request if it is erroneous | |
foreach (array_keys(get()) as $field) { | |
$errors .= $form->hasError($field) ? "\"$field\"," : ''; | |
} | |
// strip trailing comma | |
$errors = substr($errors, 0, -1); | |
?> | |
{ | |
"success": <?php e($form->successful(), 'true', 'false')?>, | |
"message": "<?php echo trim($form->message()) ?>", | |
"errors": [<?php echo $errors ?>] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment