Welcome Guest, Not a member yet? Register   Sign In
set_error_delimiters in CI 4
#1

Hello.
Is there an equivalent of "set_error_delimiters" in CI 4 when displaying errors with $validation->getError() ?
Thanks.
Reply
#2

(02-09-2022, 02:39 AM)bbsoft84 Wrote: Hello.
Is there an equivalent of "set_error_delimiters" in CI 4 when displaying errors with $validation->getError() ?
Thanks.

in Views
Code:
            $validation =  \Config\Services::validation();
            if ($validation->hasError('your_form_input_name')) {
                // show errore by YourTemplates_SINGLE templates
                echo $validation->showError('your_form_input_name','YourTemplates_SINGLE');
            }
add in app/confing/Validation.php::
Code:
    public $templates = [
        //add this line
        'YourTemplates_SINGLE'  => 'app\Views\errors\your_single.php',

        'list'  => 'CodeIgniter\Validation\Views\list',
        'single' => 'CodeIgniter\Validation\Views\single',
    ];

app\Views\errors\your_single.php::
Code:
<span class="yourCSSCLASS"><?= esc($error) ?></span>
Reply
#3

Hello, thanks for your answer. I use getError, not showError so I wrote :

echo '<div class="error">'. $validation->getError('input name') .'</div>';

For the next times I will know now.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB