You must pass an array parameter to the clean() method (this validator can only be used as a post validator).
Plik /lib/form/Uzytkownik.class.php
CODE
<?php
/**
* Uzytkownik form.
*
* @package nowy
* @subpackage form
* @author Your name here
* @version SVN: $Id: sfPropelFormTemplate.php 10377 2008-07-21 07:10:32Z dwhittle $
*/
class UzytkownikForm extends sfForm
{
public function configure()
{
$this->setWidgets(array(
'login'=> new sfWidgetFormInput(),
'haslo'=> new sfWidgetFormInputPassword(),
'powtorz'=> new sfWidgetFormInputPassword(),
'mail'=> new sfWidgetFormInput(),
));
$this->widgetSchema->setNameFormat('uzytkownik[%s]');
$this->widgetSchema->setLabels(array(
'login'=> 'Wprowadz login: ',
'haslo'=> 'Wprowadz hasło: ',
'powtorz'=> 'Powtorz haslo: ',
'mail'=> 'Wprowadz mail: '
));
$this->setValidators(array(
'login'=> new sfValidatorPropelUnique(array(
'model'=> 'Uzytkownik',
'column'=> 'login'),
array('invalid'=> 'login o tej nazwie juz istnieje')),
'haslo'=> new sfValidatorString(array(
'required'=>false, 'min_length'=> 6),
array('invalid'=> 'Hasło jest zbyt krótkie!')),
'mail'=> new sfValidatorEmail(array(), array('invalid'=> 'To ma byc prawdziwy E-mail!'))));
}
}
Controller
CODE
<?php
/**
* rejestracja actions.
*
* @package nowy
* @subpackage rejestracja
* @author Your name here
* @version SVN: $Id: actions.class.php 12479 2008-10-31 10:54:40Z fabien $
*/
class rejestracjaActions extends sfActions
{
/**
* Executes index action
*
* @param sfRequest $request A request object
*/
public function executeIndex($request)
{
$this->form = new UzytkownikForm();
if ($request->isMethod('post'))
{
$this->form->bind($request->getParameter('uzytkownik'));
if ($this->form->isValid())
{
$dane = $this->form->getValues();
$this->komunikat = 'super';
}
}
}
}
Widok:
CODE
<form method="post" action="<?php echo url_for('rejestracja/index'); ?>">
<?php echo $form; ?>
<input type="submit" name="rejestruj" />
</form>
<?php echo $komunikat; ?>
Pozdrawiam