我开始学习PHP框架,尤其是cakephp。我知道如何插入数据库,但我对在同一页面上显示条目感到好奇。我不想仅仅为了显示结果而重新加载或重定向页面。
我在数据库中只有三四个字段。id、姓名、电子邮件和日期。我在模型页面中使用了相同的验证。
控制器:
<?php
function index(){
if($this->request->is('Post')){
$this->Save->save(data);
}
//display the entries from the database
$this->set('saves', $this->Save->find('all'));
}
?>
Index.ctp:
<?php
echo $this->Form->create('Save');
echo $this->Form->input('name', array('class'=>'name', 'required' => true));
echo $this->Form->input('email', array('class'=>'email', 'required' => true));
echo $this->Form->input('message', array( 'required' => true));
echo $this->Form->submit('submit', array('formnovalidate' => true));
//i want to display the entries here
foreach($saves as $row){
echo $row['Save']['name'];
echo $row['Save']['comment'];
}
?>
问题是,它会影响文本区域。它将尺寸缩小到一半。需要帮助。非常感谢。我是cakepp的新手,我一直在谷歌上搜索,但并没有找到任何结果。感谢
据我所知,您的问题似乎更多的是CSS问题,而不是CakePHP问题。我不认为打印数据会把领域一分为二。
试着放在echo$this->Form->submit('submit',array('formnovalidate'=>true))之后;因为submit方法不包括after。
如果您不想手动添加表单结束标记,则可以结束$this->Form->end。