jak spojit komponentu s Boostrap
- Piticu
- Člen | 93
Ahoj vsem. Vytvoril jsem si komponentu SignInForm
protected function createComponentSignInForm()
{
$form = new 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');
$form->onSuccess[] = array($this, 'formSucceeded');
return $form;
}
Akorad nevim jak na to pouzit Boostrap. Vytvoril jsem si formular v souboru nette:
<form n:name=signInForm class="form-signin">
<h2 class="form-signin-heading">Sign In</h2>
<label n:name=user class="sr-only">Username: </label>
<input type="text" n:name=user class="form-control" placeholder="username" required autofocus>
<label n:name=password class="sr-only">Password</label>
<input type="password" n:name=password class="form-control" placeholder="Password" required>
<div class="checkbox">
<label>
<input type="checkbox" value="remember-me"> Remember me
</label>
</div>
<button class="btn btn-lg btn-primary btn-block" n:name=send type="submit">Sign in</button>
</form>
Problem je ze nevim jak to spojit s metodou public function
formSucceeded(Form $form, $values).
Jak teda na to?
- Piticu
- Člen | 93
David Matějka napsal(a):
a co ti nejde? hlasi to nejakou chybu? odesle se formular?
Tak kdyz smazu to co mam v nette souboru, tak prijdu o css. Kdyz smazu
protected function createComponentSignInForm()
tak dostanu error Component with name ‚signInForm‘ does not exist.. Takze asi je musim nejak spojit, ale nevim jak.
Edit:
Uz jsem pochopil jak to funguje akorat mi to nevypise chyby pokud prihlaseni selhava
try {
$this->user->login($values->username, $values->password);
$this->flashMessage('You are logged in','success');
} catch (Nette\Security\AuthenticationException $e) {
$form->addError($e->getMessage());
}
Authenticator.php
if(!$row){
throw new Nette\Security\AuthenticationException('The username is incorrect.',self::IDENTITY_NOT_FOUND);
}elseif(!Passwords::verify($password . self::$user_salt, $row[self::COLUMN_PASSWORD_HASH])){
throw new Nette\Security\AuthenticationException('The password is incorrect');
Editoval Piticu (3. 7. 2016 20:36)
- ViPEr*CZ*
- Člen | 818
Protože flash zprávy se sami nevykreslí… musíte se o to postarat sám:
https://doc.nette.org/…n/presenters#…
To samé platí u takto ručně vykreslených chyb formuláře: https://doc.nette.org/cs/forms#…