I am currently studying CakePHP with dot installation.
I'm following the video, but I'm having trouble with the title error.
Can someone tell me the mystery of the error?
http://dotinstall.com/lessons/basic_cakephp/7515
For your information, we will publish the sources of PostController, add.ctp, and index.ctp.
<?php
classPostsController extensions AppController {
public$helpers=array('Html','Form');
public function index() {
$this->set('posts', $this->Post->find('all'));
// $this->set('title', 'List of Articles');
}
public function view($id=null){
$this->Post->id=$id;
$this->set('post', $this->Post->read());
}
public function add() {
if($this->request->is('post'))){
if($this->Post->save($this->request->data)){
$this->Session->setFlash('Success!');
$this->redirect(array('action'=>'index'));
} else{
$this->Session->setFlash('failed!');
}
}
}
}
?>
<h2>Add post</h2>
<?php
echo$this->From->create('Post');
echo$this->From->input('title');
echo$this->From->input('body',array('rows'=>3));
echo$this->From->end('Save Post');
?>
<h2>List of Articles</h2>
<ul>
<?php foreach($posts as$post): ?>
<li>
<?php
// echo ($post['Post']['title']);
echo$this->Html->link($post['Post']['title'], '/posts/view/'.$post['Post']['id']);
?>
</li>
<?php endforeach;?>
</ul>
<h2>Add Post</h2>
<?php echo$this->Html->link('Add post', array('controller'=>'posts','action'=>'add'));?>
The "Stack Trace" on the error page contains information about which function was running at the point of occurrence."add.ctp line 4" tops the APP folder, but
<h2>Add post</h2>
<?php
echo$this->From->create('Post');
The error states that $this->From
in this fourth line is incorrect for $this->Form
.
© 2024 OneMinuteCode. All rights reserved.