Quantcast

got error Error: Call to a member function create() on a non-object on view

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

got error Error: Call to a member function create() on a non-object on view

anespa
 Hi Friends,

I am newbie in php , when I execute code i got error as "Error: Call to a member function create() on a non-object
File: C:\wamp\www\cakephp06\app\View\Users\index.ctp
Line: 1"

my view is :

index.ctp
==========
<?php echo $form->create(null, array('action' => 'index'));?>
<fieldset>
<legend>Enter Your Name</legend>
<?php echo $form->input('name'); ?>
</fieldset>
<?php echo $form->end('Go');?>

UsersController.php
==================
<?php
class UsersController extends AppController {
var $name = 'Users';
var $helpers = array('Form','Html');
var $uses = array();
function index() {
if (!empty($this->data)) {
//data posted
echo $this->data['name'];
$this->autoRender = false;
}
}
}
?>


pls let me know what's the error there .

Thanks
Anes





--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: got error Error: Call to a member function create() on a non-object on view

Mike Griffin
On Thu, Aug 16, 2012 at 9:57 AM, anespa <[hidden email]> wrote:

>  Hi Friends,
>
> I am newbie in php , when I execute code i got error as "Error: Call to a
> member function create() on a non-object
> File: C:\wamp\www\cakephp06\app\View\Users\index.ctp
> Line: 1"
>
> my view is :
>
> index.ctp
> ==========
> <?php echo $form->create(null, array('action' => 'index'));?>
> <fieldset>
> <legend>Enter Your Name</legend>
> <?php echo $form->input('name'); ?>
> </fieldset>
> <?php echo $form->end('Go');?>


If you're using Cake2, the create bit should be written like this:
$this->Form->create

See http://book.cakephp.org/2.0/en/core-libraries/helpers/form.html
for more details.

Mike.

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.


Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

Re: got error Error: Call to a member function create() on a non-object on view

Chetan Patel
Hello Friends,

Your file should be like that :



index.ctp
==========
<?php echo $this->Form->create('User', array('action' => 'index'));?>
   <fieldset>
     <legend>Enter Your Name</legend>
       <?php echo $this->Form->input('name'); ?>
   </fieldset>
<?php echo $this->Form->end('Go');?>

UsersController.php
==================
<?php
class UsersController extends AppController {
    var $name = 'Users';
    var $helpers = array('Form','Html');
    var $uses = array('User');
   
    function index() {
         if (!empty($this->data)) {
         $this->autoRender = false;
         $this->layout = NULL;       
                //data posted
                pr($this->data);
             
            }
         }
}
?>


--
Thanks & Regards

Chetan Patel

--
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to [hidden email].
To unsubscribe from this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/cake-php?hl=en-US.
 
 
Loading...