Help with controller and view

edited June 2012 in News & Announcements

I am trying to create a page with a form which will be submitted to the database.

I created a view file called: test.php

And this is my controller:
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');

class Test extends CI_Controller
function __construct()

function index()

if ($this->_process($_POST))


$fields = array();
$fields['category'] = array('required' => TRUE);
$fields['adtype'] = array('required' => TRUE, 'type'=>'select');


// will set the values of the fields if there is an error... must be after set_fields
$this->form_builder->display_errors = TRUE;
$this->form_builder->required_text = '*required fields';
$vars['form'] = $this->form_builder->render();

// use Fuel_page to render so it will grab all opt-in variables and do any necessary parsing
$page_init = array('location' => 'test');
$this->load->module_library(FUEL_FOLDER, 'fuel_page', $page_init);

When I go to this page in the browser, the page is empty, there is no form in it.

Can you please help?


  • edited 3:06PM
    Ok, found out I need to add echo $form; in my view.

Sign In or Register to comment.