Component with name ‚SignInForm‘ does not exist

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
Andurit
Člen | 131
+
0
-

Ahojte, dostávam error
Component with name ‚SignInForm‘ does not exist

Ono je to vcelku vymluvne ale stejne nechapu moc kde mam chybu,

moj Base Presenter:

<?php

/**
 * Base presenter for all application presenters.
 */
<?php
abstract class BasePresenter extends Nette\Application\UI\Presenter
{
    public function createComponentSignInForm ()
	{
		$form = new UI\Form;
		$form->addText('username', 'Username:')
			->setRequired('Please enter your username.');

		$form->addPassword('password', 'Password:')
			->setRequired('Please enter your password.');

		$form->addCheckbox('remember', 'Keep me signed in');

		$form->addSubmit('send', 'Sign in');

		// call method signInFormSucceeded() on success
		$form->onSuccess[] = $this->signInFormSucceeded;
		return $form;
	}


	public function signInFormSucceeded($form)
	{
		$values = $form->getValues();

		if ($values->remember) {
			$this->getUser()->setExpiration('14 days', FALSE);
		} else {
			$this->getUser()->setExpiration('20 minutes', TRUE);
		}

		try {
			$this->getUser()->login($values->username, $values->password);
			$this->redirect('Homepage:');

		} catch (Nette\Security\AuthenticationException $e) {
			$form->addError($e->getMessage());
		}
	}


	public function actionOut()
	{
		$this->getUser()->logout();
		$this->flashMessage('You have been signed out.');
		$this->redirect('in');
	}
}
?>

a môj banned presenter:

<?php
<?php

use Nette\Application\UI\Form;


class BannedPresenter extends BasePresenter
{
	/** @var AlbumRepository */
	private $banned;


	/** @persistent */
	public $search='';


	public function inject(Banned $banned)
	{
		$this->banned = $banned;
	}


	protected function startup()
	{
		parent::startup();
	}

	public function LoggedUser()
	{
		if (!$this->user->isLoggedIn()) {
			if ($this->user->logoutReason === Nette\Http\UserStorage::INACTIVITY) {
				$this->flashMessage('Bol si odhlasený.');
			}
			$this->redirect('banned', array('backlink' => $this->storeRequest()));
		}
	}


	/********************* view default *********************/


	public function renderDefault()
	{
		$this->template->banned = $this->banned->findAll()->order('id')->order('admin');
		$vp = new VisualPaginator($this, 'vp');
		$paginator = $vp->getPaginator();
		$paginator->itemsPerPage = 20;
		$paginator->itemCount = $this->template->banned->count('*');
		$searchWord = $this->search;
		if (!$searchWord){
		$this->template->banned = $this->banned->findAll()->order('id, admin')->limit($paginator->itemsPerPage,$paginator->offset);
		} else { $this->template->banned = $this->banned->findAll()->select('*')->where("name LIKE ?", "%$searchWord%"); }
	}


	/********************* views add & edit *********************/


	public function renderAdd()
	{
		$this['albumForm']['save']->caption = 'Add';
		//$this['searchForm']['search']->caption = 'Hľadať';
	}

	public function renderEdit($id = 0)
	{
		$form = $this['albumForm'];
		if (!$form->isSubmitted()) {
			$banned = $this->banned->findById($id);
			if (!$banned) {
				$this->error('Record not found');
			}
			$form->setDefaults($banned);
		}
	}


	/********************* view delete *********************/


	public function renderDelete($id = 0)
	{
		$this->template->banned = $this->banned->findById($id);
		if (!$this->template->banned) {
			$this->error('Record not found');
		}
	}


	/********************* component factories *********************/


	/**
	 * Edit form factory.
	 * @return Form
	 */
	protected function createComponentAlbumForm()
	{
		$this->LoggedUser();
		$form = new Form;
		$form->addText('name', 'Zabanovany:')
			->setRequired('Vlozte nick zabanovaneho hraca.');

		$form->addText('reason', 'Dovod:')
			->setRequired('Prosim vlozte dovod banu.');

		$form->addSubmit('save', 'Save')
			->setAttribute('class', 'default')
			->onClick[] = $this->albumFormSucceeded;

		$form->addSubmit('cancel', 'Cancel')
			->setValidationScope(NULL)
			->onClick[] = $this->formCancelled;

		$form->addProtection();
		return $form;
	}


	public function albumFormSucceeded($button)
	{
		$values = $button->getForm()->getValues();
		$id = (int) $this->getParameter('id');
		if ($id) {
			$this->banned->findById($id)->update($values);
			$this->flashMessage('Ban bol upravený.');
		} else {
			$this->banned->insert($values);
			$this->flashMessage('Ban bol pridany.');
		}
		$this->redirect('default');
	}


	protected function createComponentDeleteForm()
	{
		$form = new Form;
		$form->addSubmit('cancel', 'Cancel')
			->onClick[] = $this->formCancelled;

		$form->addSubmit('delete', 'Delete')
			->setAttribute('class', 'default')
			->onClick[] = $this->deleteFormSucceeded;

		$form->addProtection();
		return $form;
	}


	public function deleteFormSucceeded()
	{
		$this->banned->findById($this->getParameter('id'))->delete();
		$this->flashMessage('Ban bol zmazany!');
		$this->redirect('default');
	}


	public function formCancelled()
	{
		$this->redirect('default');
	}

	public function searchsucceeded($form)
	{
		$values = $form->getValues();
		//$this->banned->findAll()->select('*')->where("name LIKE ?", "%$searchword%");
		//$this->template->searchresult = $searchresult;
		$this->search=$values->name;
		$this->redirect('this');
    }

    protected function createComponentSearchForm()
	{
		$defaults = array('name' => $this->search);

 		$form = new Form;
        $form->addText('name', 'Vlož nick hráča')->setAttribute('placeholder', 'Vyhľadať ban...vložte nick hráča');
        $form->addSubmit('search', 'Hľadať');
        $form->onSuccess[] = callback($this, 'searchsucceeded');
        $form->setDefaults($defaults);
        return $form;
	}


}
?>

Editoval Andurit (22. 12. 2013 23:16)

petr.pavel
Člen | 535
+
0
-

Ve kterém souboru a na které řádce to hlásí tu chybu?

Andurit
Člen | 131
+
0
-

petr.pavel napsal(a):

Ve kterém souboru a na které řádce to hlásí tu chybu?

File: …\libs\Nette\ComponentModel\Container.php Line: 160

prikladam pre istotu este layout.latte

<?php
{**
 * My Application layout template.
 *
 * @param string   $basePath web base path
 * @param string   $robots   tell robots how to index the content of a page (optional)
 * @param array    $flashes  flash messages
 *}

<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">

	<title>{block title}Banlist | gamesites.cz{/block}</title>

	<link rel="stylesheet" media="screen,projection,tv" href="{$basePath}/css/bootstrap.css">
	<link rel="stylesheet" href="{$basePath}/css/my.css">
	<link rel="shortcut icon" href="{$basePath}/favicon.ico">

	{block head}{/block}
</head>

<body>
	<div class="container">

	<div id="demo-header">
	<!-- Code for Login Link --> <a id="login-link" title="Login" href="#login">Prihlásenie</a> <!-- Code for login panel -->

  	<div id="login-panel">
	{form SignInForm}
	{/form}
	<form action="#" method="post">
	<label>Meno: <input type="text" name="username" value=""> </label>
	<label>Heslo: <input type="password" name="password" value=""> </label>
	<input type="submit" name="submit" value="Prihlásiť"> <small>Pre zatvorenie stlač ESC</small></form>
	</div><!-- login-panel ends here -->

  	</div><!-- demo-header ends here -->}

	<header><a href="{link Banned:default, search => ''}"><img src="/mcbanlist/sandbox/www/images/banlist.png" alt="" /></a></header>
	{form searchForm}
	<span style="margin-top:10px">{input name class=>'span10'}</span>
	{input search class=>'btn btn-primary span2'}
	{/form}
	<div n:foreach="$flashes as $flash" class="flash {$flash->type}">{$flash->message}</div>

	{include #content}

	{block scripts}
	<script src="{$basePath}/js/jquery.js"></script>
	<script src="{$basePath}/js/netteForms.js"></script>
	<script src="{$basePath}/js/main.js"></script>
	<script type="text/javascript" src="{$basePath}/js/newjquery.js"></script>

<!-- jQuery to apply actions to the link -->
<script type="text/javascript">// <![CDATA[
$(document).ready(function(){
    $("#login-link").click(function(){
        $("#login-panel").slideToggle(200);
    })
})
<!-- jQuery to apply actions to the ESC key -->
$(document).keydown(function(e) {
    if (e.keyCode == 27) {
        $("#login-panel").hide(0);
    }
});
// ]]>
</script>
	{/block}
</body>
</html>

?>

Editoval Andurit (23. 12. 2013 0:04)

jiri.pudil
Nette Blogger | 1028
+
0
-

První písmeno malé:

{form signInForm}
Andurit
Člen | 131
+
0
-

Okey, toto som si teda mal vsimnut sam. Kazdopadne sice sa stranka vypise normalne, bohuzial nezobrazi mi to ziaden formular na signin :(

David Matějka
Moderator | 6445
+
0
-

makro {form} se pouziva pro manualni renerovani. pro automaticke renderovani pouzij {control signInForm}

Editoval matej21 (23. 12. 2013 0:35)

Andurit
Člen | 131
+
0
-

skvele ide to, vďaka. Možno mala otazocka. Ako tam narvem to CSSko tak aby to vyzeralo stejne jako
<form action=„#“ method=„post“>
<label>Meno: <input type=„text“ name=„username“ value=""> </label>
<label>Heslo: <input type=„password“ name=„password“ value=""> </label>
<input type=„submit“ name=„submit“ value=„Prihlásiť“> <small>Pre zatvorenie stlač ESC</small></form>

David Matějka
Moderator | 6445
+
0
-

pokud to chces mit ve specifickem formatu, budes si bud muset upravit renderer (respektive jeho nastaveni) nebo vykreslit manualne pomoci onoho form makra, stejne, jako vykreslujes treba searchForm

vse o manualnim renderovani nebo upravach rendereru je v dokumentaci https://doc.nette.org/cs/forms