James F
James F

Reputation: 554

CakePHP AJAX form with Server-side model validation

When a normal form in CakePHP is submitted, if it fails model validation, it puts

<div class="error-message">_validation error_</div>

after each input in the form that has an error. How can you incorporate this into forms that are submitted with AJAX?

Upvotes: 0

Views: 797

Answers (1)

floriank
floriank

Reputation: 25698

Return the form as HTML or return json data of the validation messages and add the error divs to the field via javascript. You can get all errors for all models from Controller::$validationErrors. See http://api.cakephp.org/2.4/source-class-Controller.html#287

Upvotes: 1

Related Questions