This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
My form:
{{ form_ajax('onUpdate') }}
<input type="text" name="first_name" value="{{ profile.first_name }}">
<input type="text" name="last_name" value="{{ profile.last_name }}">
...
<button type="submit" id="update-data" class="btn btn-success">Update</button>
{{ form_close() }}
My component:
public function onUpdate()
{
$data = post();
$rules = ['first_name' => 'required|between:2,255',
'last_name' => 'required|between:2,255'
];
$validation = Validator::make($data, $rules);
if ($validation->fails()) {
throw new ValidationException($validation);
}
...
$profile->update($data);
}
Now if a field is not properly filled in, I get a warning message and the field gets the focus wich is the expected behaviour.
However, I noticed it generates an error in the JS console:
POST https://mydomain.net/mywebsite/profile 406 (Not Acceptable)
XHR failed loading: POST "https://mydomain.net/mywebsite/profile".
I have no idea where this error comes from.
Can someone help me ?
EDIT:
Actually it looks like it's a general issue in October.
In the User plugin for instance, if the "Email" field is left empty a warning message pops up as expected, but a "406 (Not Acceptable)" error appears in the JS console.
Should I report it as a bug ?
Last updated
Ok I got it now. It's explained here: https://github.com/octobercms/october/issues/3655
Since I'm throwing an exception that halts execution and informs the user that the request was unacceptable, it's logical to have an error in the JS console.
I didn't see it that way in the first place, but it makes sense now.
1-2 of 2