-
Notifications
You must be signed in to change notification settings - Fork 1.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
validation form_error() #911
Comments
You are correct, See the Validation docs for a (hopefully) up to date explanation. |
so sad heard dat the form_error helper is removed on ci4, it is very helpful |
@akrindev It's not needed. use In controller:
In view:
|
Controller <?php
namespace App\Controllers;
use CodeIgniter\Controller;
class UserController extends Controller
{
public function login()
{
helper('form');
echo view('header');
echo view('login');
echo view('footer');
}
public function loginPost()
{
if(! $this->validate([
'email' => 'required|valid_email',
'password' => 'required'
]))
{
return $this->login();
}
// everything is fine
}
} view <div class="form-group form-group-sm">
<label>email or username</label>
<input type="text" name="email" class="form-control">
<?= form_error('email'); ?>
</div> if we want if( ! function_exists('form_error'))
{
function form_error(string $field = '', string $template = 'single')
{
return Services::validation()->showError($field, $template);
}
} but redirecting with input is fine ;) |
Why theres no helper form_error() like ci3?
https://bcit-ci.github.io/CodeIgniter4/helpers/form_helper.html
The doc describe abt form_error
But theres no function form_error
https://github.com/bcit-ci/CodeIgniter4/blob/develop/system/Helpers/form_helper.php
The text was updated successfully, but these errors were encountered: