• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
problem when Template using form helper

#1
[eluser]Unknown[/eluser]
Hi

i am new baby to CI, i don't know how to use form helper in template.i don't want to use any php code on my template. can anyone help me?

This is my controller

Code:
class Welcome extends Controller {

    function Welcome()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
                $this->load->library('parser');
    }
        function index()
    {
        $data['title']='This is my title';
        $data['heading']='My heading is different';
        
                $this->parser->parse('template_welcome_message',$data);
    }
}

here is my template

Code:
<html>
<head>
<title>{title}</title>
</head>
<body>
<h1>{heading}</h1>

{form_open('welcome/mysubmit')}
{form_input('username','')}
{form_input('pword','')}
{form_submit('mysubmit','submit')}
{form_close()}
&lt;/body&gt;
&lt;/html&gt;

#2
[eluser]xwero[/eluser]
I don't think you can add 'raw' php to the template. If you want to use the form functions you have to do
Code:
$data['title']='This is my title';
$data['heading']='My heading is different';
$data['form_open']=form_open('welcome/mysubmit');
$data['username']=form_input('username','');
$data['pword']=form_input('pword','');
$data['submit']=form_submit('mysubmit','submit');
$data['form_close']=form_close();
        
$this->parser->parse('template_welcome_message',$data);
// template
{form_open}
{username}
{pword}
{submit}
{form_close}

#3
[eluser]Unknown[/eluser]
Thanks xwero , your solution is great


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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