Welcome Guest, Not a member yet? Register   Sign In
20 min Tutorial - Problem with Form Helper
#1

[eluser]Unknown[/eluser]
Hi All,

I am working my way through the 20 min tutorial and have a problem that I cannot solve.

The form helper does not seem to be working.

Here is my view

Code:
<html>
    <head>
        <title><?php echo $title; ?></title>
    </head>
    <body>
    
        <h1>&lt;?php echo $heading; ?&gt;</h1>
        
        &lt;?php form_open('blog/comment_insert'); ?&gt;
            
        &lt;?php form_hidden('entry_id', $this->uri->segment(3)); ?&gt;
            
        <p>&lt;textarea nasme-"body" rows="10"&gt;&lt;/textarea></p>
        <p>&lt;input type="text" name="author" /&gt;&lt;/p>
        <p>&lt;input type="submit" value="Submit Comment" /&gt;&lt;/p>
        
        &lt;/form&gt;
    &lt;/body&gt;
&lt;/html&gt;

Here is my controller

Code:
&lt;?php

class Blog extends Controller {
    
    function Blog()
    {
        parent::Controller();
        $this->load->helper('url');
        $this->load->helper('form');
        
    }
    
    function index()
    {
        $data['title'] = 'My BLog Title';
        $data['heading'] = 'My Blog Heading';
        $data['query'] = $this->db->get('entries');
        
        $this->load->view('blog_view', $data);
    }
    
    function comments()
    {
        $data['title'] = 'My Comment Title';
        $data['heading'] = 'My Comment Heading';
                
        $this->load->view('comment_view', $data);    
    }
    
    function comment_insert()
    {
        echo "testing...";
    }
    
    
}

?&gt;

When I view my page I do not get a form opening tag or the hidden field. I checked and the file form_helper.php exists under System/Helpers.

Can anyone see my mistake?

Thanks,
DDetto
#2

[eluser]wiredesignz[/eluser]
Use echo.

Code:
&lt;?php echo form_open(...
Try reading the CodeIgniter user guide or even the source code when you get stuck (before you ask).

In this case try system/helpers/form_helper.php
#3

[eluser]Unknown[/eluser]
Thanks for the help. That fixed it. I actually did quite a bit of reading and testing. I only asked after working on it for a while and even then I thought twice because I knew it would be somehting obvious to an experienced user. Also, I apologize because I am new to PHP so I am dealing with a bit of a learning curve.




Theme © iAndrew 2016 - Forum software by © MyBB