Quickstart Tutorial -postpresenter

8 months ago

rickylorenco
Member | 3
+
0
-

Hello!
So far I like this framework.
I followed the quickstart tutorial but I get this error in the postPresenter:

Argument 1 passed to Nette\Database\Table\ActiveRow::update() must be iterable, object given, called in C:\xampp\htdocs\nett\app\presenters\PostPresenter.php on line 89

: $this->error(‘Post not found’);
80: }
81: $this[‘postForm’]->setDefaults($post->toArray());
82: }
83: public function postFormSucceeded(Form $form, \stdClass $values): void
84: {
85: $postId = $this->getParameter(‘postId’);
86:
87: if ($postId) {
88: $post = $this->database->table(‘posts’)->get($postId);
89: $post->update($values);
90: } else {
91: $post = $this->database->table(‘posts’)->insert($values);
92: }
93:

8 months ago

Martk
Member | 534
+
+2
-
public function postFormSucceeded(Form $form, array $values): void {
	$postId = $this->getParameter('postId');

	if ($postId) {
		$post = $this->database->table(‘posts’)->get($postId);
		$post->update($values);
	} else {
		$post = $this->database->table(‘posts’)->insert($values);
	}
}

Next time please, format your code , it's better :)

8 months ago

rickylorenco
Member | 3
+
0
-

Thanks! Let's move on