• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Validation Always Print Error Message

#1
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

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.