Component with name ‚.‘ does not exist
Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
- mi85
- Člen | 41
Čau snažím se volat factory a tracy mi vypisuje
Component with name 'PostForm' does not exist.
volám ji
<form n:name="PostForm">
<table align="center">
<tr>
<td><input type="text" n:name="title" placeholder="Titulek"></td>
</tr>
<tr>
<td><input type="text" n:name="content" placeholder="Obsah"></td>
</tr>
</table>
PostFormFactory
<?php
namespace App\Presenters\Components;
use Nette\Application\UI\Form;
use Nette;
use Nette\Database\Context;
class PostFormFactory extends Nette\Application\UI\Presenter{
public function __construct(Nette\Database\Context $context)
{
$this->database = $context;
}
/**
* @return Form
*/
public function create()
{
$form = new Form();
$form->addTextArea('title', 'Titulek:')
->setRequired();
$form->addTextArea('content', 'Obsah:')
->setRequired();
$form->addSubmit("submit");
$form->onSuccess[] = [$this, 'postFormSucceeded'];
return $form;
}
public function postFormSucceeded($form, $values)
{
$presenter = $form->getPresenter();
$this->database->table('posts')->insert([
'author' => $this->getUser()->getIdentity()->getId()['name'],
'content' => $values->content,
'title' => $values->title,
]);
$presenter->redirect('this');
}
PostPresenter
public function createComponentPost()
{
$factory = $this->postFormFactory;
$factory->setField('chyba jmena ......');
return $factory->create();
}
a config
- App\Presenters\Components\PostFormFactory
Díky za rady