0
votes

I use cakephp 2.3.1 and trying to creat a form with formhelper.

This is my addStudent.ctp :

<?php
$this->Form->create("Test");
$this->Form->input("stuId",array('class'=>'inputField', 'placeholder'=>'SVxxxxxxxx'));
$this->Form->input("stuName",array('class'=>'inputField', 'name'=>'stuName'));
$this->Form->input('submit',array('type'=>'submit'));
$this->Form->end();
?>

I've already add : var $helpers= array('Form'); in AppController. But it show nothing ? what is the problem here:(

1

1 Answers

2
votes

You need to echo the output to the browser. Remember that you are using functions here that return html. But in order for it to be displayed on the page it has to be echo-ed. Try this:

<?php
echo $this->Form->create("Test");
echo $this->Form->input("stuId",array('class'=>'inputField', 'placeholder'=>'SVxxxxxxxx'));
echo $this->Form->input("stuName",array('class'=>'inputField', 'name'=>'stuName'));
echo $this->Form->input('submit',array('type'=>'submit'));
echo $this->Form->end();
?>