Welcome Guest, Not a member yet? Register   Sign In
v4.3.1 released
#11

I don't know why you can't use validation_show_error('email');

The following code works as before after you run validation.
PHP Code:
if ($validation->hasError('username')) {
    echo $validation->getError('username');


If you have code like this,
PHP Code:
if (! $this->validate($rules)) {
    return redirect()->back()->withInput();

you are redirected after the validation fails.
In the next request, validation never run.
So you no longer can use $validation->getError() or hasError().

That is, if you don't redirect after the validation fails,
you can use $validation->getError() or hasError().
Reply
#12

(01-22-2023, 05:49 AM)kenjis Wrote: I don't know why you can't use validation_show_error('email');

The following code works as before after you run validation.
PHP Code:
if ($validation->hasError('username')) {
    echo $validation->getError('username');


If you have code like this,
PHP Code:
if (! $this->validate($rules)) {
    return redirect()->back()->withInput();

you are redirected after the validation fails.
In the next request, validation never run.
So you no longer can use $validation->getError() or hasError().

That is, if you don't redirect after the validation fails,
you can use $validation->getError() or hasError().

Ok thanks kenjis now everything is clearer to me.

But even to me it's a mystery that it doesn't work (it shows nothing):

PHP Code:
echo validation_show_error('email'); 

Instead this shows the error correctly:

PHP Code:
if (isset($errors['email']))
{
    echo $errors['email'];

Reply
#13

(01-22-2023, 08:11 AM)chronic Wrote:
(01-22-2023, 05:49 AM)kenjis Wrote: I don't know why you can't use validation_show_error('email');

The following code works as before after you run validation.
PHP Code:
if ($validation->hasError('username')) {
    echo $validation->getError('username');


If you have code like this,
PHP Code:
if (! $this->validate($rules)) {
    return redirect()->back()->withInput();

you are redirected after the validation fails.
In the next request, validation never run.
So you no longer can use $validation->getError() or hasError().

That is, if you don't redirect after the validation fails,
you can use $validation->getError() or hasError().

Ok thanks kenjis now everything is clearer to me.

But even to me it's a mystery that it doesn't work (it shows nothing):

PHP Code:
echo validation_show_error('email'); 

Instead this shows the error correctly:

PHP Code:
if (isset($errors['email']))
{
    echo $errors['email'];


Ok I found my problem, it was due to my "single" custom templates specified in Config/Validation.php.

Thanks again kenjis, and sorry for boring you
Reply




Theme © iAndrew 2016 - Forum software by © MyBB