Welcome Guest, Not a member yet? Register   Sign In
Validation Always Print Error Message
#1

(This post was last modified: 03-31-2019, 03:52 AM by rmcdahal.)

Here is my Controller

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 ?
Reply


Messages In This Thread
Validation Always Print Error Message - by rmcdahal - 03-31-2019, 03:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB