We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Can't load form in view from controller

News and General

baby89's avatar
baby89
3 posts
11 years ago
baby89's avatar baby89

I’m trying to make a form, but it can’t be loaded in view. I’m using Bootstrap.My controller code is:

<?php

class Boot extends CI_Controller {
   public function __construct() {
        parent::__construct();
    }
    
    function index() {
 
  $this->load->helper('form');
        $this->load->library('form_validation');
        
  $this->load->view('bootview');
        $this->load->view('forma');
      
 }
}

My view is:

<html>
<head>
<link rel="stylesheet"  href="<?php echo base_url("assets/css/bootstrap.css"); ?>" />
</head>
<body>
<h2>Create a news item</h2>

 <?php echo validation_errors(); ?>

 <?php echo form_open('boot/index') ?>
  <div class="form-group">
  
  <label for="name">Name:</label>
  <input type="text" id="name" class="form-control" autofocus name="name" placeholder="Name"></br></br>
  <input type="submit" name="submit" value="Create news item" />
  </div>
 </form>
       
baby89's avatar
baby89
3 posts
11 years ago
baby89's avatar baby89

I made it..

       
fnbhns's avatar
fnbhns
22 posts
11 years ago
fnbhns's avatar fnbhns

Dear Baby,

The view you mentioned here, what is the name of that view. Beside this 2 views at a time you trying to display that is in the controller, Better avoid one.

$this->load->view('bootview');
       //  $this->load->view('forma');

if you have more view to display in a page. that mean you should have Master view and all child view has to store in the Variable and then these variable have to pass it in the Master view.

<?php

Beside this we can include our helper files or any other files in the Construct funciton''s, so far i know which is the best practice.

class Boot extends CI_Controller {
   public function __construct() {
        parent::__construct();
        $this->load->helper('form');
        $this->load->library('form_validation');

    }
    
    function index() {                
        $this->load->view('bootview');
      //  $this->load->view('forma');      
 }
}

If you not solved it yet. Hope it will help you.

       
baby89's avatar
baby89
3 posts
11 years ago
baby89's avatar baby89

Thanks for answer, I call views in this way already, because too many views and I have a Master one. 😊

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.