title: Input Form Using Codeigniter and Bootstrap 3
body: <p>I'm using Codeigniter, styled with Bootstrap 3 to build a website.</p>
  
  <p>I can't stylize the text-fields built by the PHP/Form Helper, as I'm not sure where to use the tags, every solution I've tried has resulted in either an extra text field, or just the addon appearing, or nothing at all.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>public function __construct ()
  {
      parent::__construct();
  }
  
  public function index ()
  {
      // Fetch all users
      $this-&gt;data['users'] = $this-&gt;user_m-&gt;get();
  
      // Load view
      $this-&gt;data['subview'] = 'admin/user/index';
      $this-&gt;load-&gt;view('admin/_layout_main', $this-&gt;data);
  }
  
  public function edit ($id = NULL)
  {
      // Fetch a user or set a new one
      if ($id) {
          $this-&gt;data['user'] = $this-&gt;user_m-&gt;get($id);
          count($this-&gt;data['user']) || $this-&gt;data['errors'][] = 'User could not be found';
      }
      else {
          $this-&gt;data['user'] = $this-&gt;user_m-&gt;get_new();
      }
  
      // Set up the form
      $rules = $this-&gt;user_m-&gt;rules_admin;
      $id || $rules['password']['rules'] .= '|required';
      $this-&gt;form_validation-&gt;set_rules($rules);
  
      // Process the form
      if ($this-&gt;form_validation-&gt;run() == TRUE) {
          $data = $this-&gt;user_m-&gt;array_from_post(array('name', 'email', 'password'));
          $data['password'] = $this-&gt;user_m-&gt;hash($data['password']);
          $this-&gt;user_m-&gt;save($data, $id);
          redirect('admin/user');
      }
  
      // Load the view
      $this-&gt;data['subview'] = 'admin/user/edit';
      $this-&gt;load-&gt;view('admin/_layout_main', $this-&gt;data);
  }
  
  public function delete ($id)
  {
      $this-&gt;user_m-&gt;delete($id);
      redirect('admin/user');
  }
  
  public function login ()
  {
      // Redirect a user if he's already logged in
      $dashboard = 'admin/dashboard';
      $this-&gt;user_m-&gt;loggedin() == FALSE || redirect($dashboard);
  
      // Set form
      $rules = $this-&gt;user_m-&gt;rules;
      $this-&gt;form_validation-&gt;set_rules($rules);
  
      // Process form
      if ($this-&gt;form_validation-&gt;run() == TRUE) {
          // We can login and redirect
          if ($this-&gt;user_m-&gt;login() == TRUE) {
              redirect($dashboard);
          }
          else {
              $this-&gt;session-&gt;set_flashdata('error', 'That email/password combination does not exist');
              redirect('admin/user/login', 'refresh');
          }
      }
  
      // Load view
      $this-&gt;data['subview'] = 'admin/user/login';
      $this-&gt;load-&gt;view('admin/_layout_modal', $this-&gt;data);
  }
  
  public function logout ()
  {
      $this-&gt;user_m-&gt;logout();
      redirect('admin/user/login');
  }
  
  public function _unique_email ($str)
  {
      // Do NOT validate if email already exists
      // UNLESS it's the email for the current user
  
      $id = $this-&gt;uri-&gt;segment(4);
      $this-&gt;db-&gt;where('email', $this-&gt;input-&gt;post('email'));
      !$id || $this-&gt;db-&gt;where('id !=', $id);
      $user = $this-&gt;user_m-&gt;get();
  
      if (count($user)) {
          $this-&gt;form_validation-&gt;set_message('_unique_email', '%s should be unique');
          return FALSE;
      }
  
      return TRUE;
    }
  }
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>    &lt;div class="modal-body"&gt;
  &lt;?php echo validation_errors(); ?&gt;
  &lt;?php echo form_open();?&gt;
  
  &lt;div class="container"&gt;
      &lt;div class="modal-header"&gt;
      &lt;h3&gt;Log in&lt;/h3&gt;
      &lt;p&gt;Please log in using your credentials&lt;/p&gt;
  &lt;/div&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;td&gt;Email&lt;/td&gt;
          &lt;td&gt;&lt;?php echo form_input('email'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;Password&lt;/td&gt;
          &lt;td&gt;&lt;?php echo form_password('password'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;/td&gt;
          &lt;td&gt;&lt;?php echo form_submit('submit', 'Log in', 'class="btn btn-primary"'); ?&gt;&lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
          &lt;div class="modal-footer"&gt;
              &amp;copy; &lt;?php echo date('Y'); ?&gt; &lt;?php echo $meta_title; ?&gt;
          &lt;/div&gt;
  &lt;?php echo form_close();?&gt;
  
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p><strong>Bootstrap</strong></p>
  
  <pre><code>      &lt;form class="form-signin" role="form"&gt;
      &lt;h2 class="form-signin-heading"&gt;Please sign in&lt;/h2&gt;
      &lt;input type="text" class="form-control" placeholder="email" required autofocus value="&lt;?php echo set_value('email') ?&gt;"&gt;
      &lt;input type="password" class="form-control" placeholder="password" required value"&lt;?php echo set_value('password') ?&gt;"&gt;
      &lt;label class="checkbox"&gt;
        &lt;input type="checkbox" value="remember-me"&gt; Remember me
      &lt;/label&gt;
      &lt;button class="btn btn-lg btn-primary btn-block" type="submit"&gt;Sign in&lt;/button&gt;
    &lt;/form&gt;
  </code></pre>