Input.post
Input.post(paramName, validationRule='id')
Description
Get an input field sent in a POST request (usually via a form or Ajax request).
It will be validated per $validationRule
. (See Input Validation)
If $validationRule
is an empty string, it will look for a rule that is contained in the field name.
SecurityPost requests must come from the same origin and contain a CSRF token, which you can get via
Web.csrfToken()
. Use Input.remote
if you wish to accept requests without these safeguards.// post data: { userId: 12345, age: 39 } Input.post('userId', 'id'); //= 12345 // Uses 'id' rule because the name ends in '-id' Input.post('userId'); //= 12345 Input.post('age', 'i|min:1|max:130'); //= 39 Input.post('age', 'old'); //= '' (invalid)