Here is my Controller
Here is my Views
And issue is Views always print validation error message withour submiting form ?
The title field is required.
The body field is required.
Is there any problems with my code ?
Code:
public function pagecreate()
{
$validation = $this->validate([
'title' => 'required',
'body' => 'required'
]);
if (!$validation) {
$data['page_heading'] = 'Create New Page';
$data['content_view'] = 'Backend/Pages/Create';
echo view('Backend/Themes/Base', $data);
} else {
$this->model->save(
[
'title' => $this->request->getvar('title'),
'content' => $this->request->getVar('body')
]
);
return redirect()->to('');
}
}Here is my Views
Code:
<div class="row">
<div class="col-md-12">
<div class="card-box">
<h4 class="m-t-0 header-title"><?php echo $page_heading; ?></h4>
<?= service('validation')->listErrors() ?>
<?php echo form_open('admin/pages/create'); ?>And issue is Views always print validation error message withour submiting form ?
The title field is required.
The body field is required.
Is there any problems with my code ?