CodeIgniter Forums
v4.3.1 released - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: General (https://forum.codeigniter.com/forumdisplay.php?fid=1)
+--- Forum: News & Discussion (https://forum.codeigniter.com/forumdisplay.php?fid=2)
+--- Thread: v4.3.1 released (/showthread.php?tid=86136)

Pages: 1 2


RE: v4.3.1 released - kenjis - 01-22-2023

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().


RE: v4.3.1 released - chronic - 01-22-2023

(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'];




RE: v4.3.1 released - chronic - 01-22-2023

(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