Yanor.net/
Wiki
Blog
GitHub
Sandbox
開始行:
* Propelフォーム [#k8fc63a1]
** フォームクラス作成 [#ef050eac]
symfony propel:build-form
** 基底フォームクラス [#z33ab8b7]
class BaseMemberForm extends BaseFormPropel
{
public function setup()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(),
'name' => new sfWidgetFormInput(),
));
$this->setValidators(array(
'id' => new sfValidatorPropelChoice(array('mode...
'name' => new sfValidatorString(array('max_length...
));
(略)
}
- lib/form/base/BaseMemberForm.class.php
- 基底フォームクラスはデータベースを基に自動的に生成され...
** 派生フォームクラス [#v67dab8c]
class MemberForm extends BaseMemberForm
{
public function configure()
{
$this->widgetSchema['name'] = new sfWidgetFormInput();
$this->widgetSchema->setLabel('name', '名前');
$this->validatorSchema['name'] = new sfValidatorStri...
$this->validatorSchema['name']->setMessage('min_leng...
$this->validatorSchema['name']->setOption('min_lengt...
$this->validatorSchema['name']->setOption('required'...
$this->validatorSchema['name']->setMessage('required...
(略)
}
}
- lib/form/MemberForm.class.php
- 派生フォームクラスに、業務に基づいたヴァリデーションや...
** コントローラ [#xda90f6c]
public function executeInput(sfWebRequest $request)
{
$this->form = new MemberForm();
}
public function executeRegister(sfWebRequest $request)
{
$member = $request->getParameter('member');
$this->form->bind($member);
if( $this->form->isValid() === true ){
// $memberをDBに入れる
} else {
$this->getUser()->setAttribute('member_data', $membe...
$this->redirect('entry/input');
}
}
** テンプレート [#hbec0073]
<form action="<?php echo url_for('entry/register') ?>" m...
名前:<?php echo $form['name'] ?><br />
<?php if( $form['name']->hasError() === true ) { ?>
エラー:<?php echo $form['name']->getError() ?><br...
<?php } ?>
<input type="submit" />
</form>
- inputSuccess.php
** ウィジェット・バリデータ [#q69fa0f1]
*** ウィジェット [#kdb4791b]
- http://www.symfony-project.org/forms/1_2/ja/A-Widgets
*** バリデータ [#n41419d6]
- sfValidatorString
- sfValidatorRegex
- sfValidatorEmail
- sfValidatorUrl
- sfValidatorInteger
- sfValidatorNumber
- sfValidatorBoolean
- sfValidatorChoice
- 他
http://www.symfony-project.org/forms/1_2/ja/B-Validators
** 参考 [#x1178737]
- http://www.symfony-project.org/tutorial/1_2/ja/my-first...
- http://www.symfony-project.org/forms/1_2/ja/01-Form-Cre...
終了行:
* Propelフォーム [#k8fc63a1]
** フォームクラス作成 [#ef050eac]
symfony propel:build-form
** 基底フォームクラス [#z33ab8b7]
class BaseMemberForm extends BaseFormPropel
{
public function setup()
{
$this->setWidgets(array(
'id' => new sfWidgetFormInputHidden(),
'name' => new sfWidgetFormInput(),
));
$this->setValidators(array(
'id' => new sfValidatorPropelChoice(array('mode...
'name' => new sfValidatorString(array('max_length...
));
(略)
}
- lib/form/base/BaseMemberForm.class.php
- 基底フォームクラスはデータベースを基に自動的に生成され...
** 派生フォームクラス [#v67dab8c]
class MemberForm extends BaseMemberForm
{
public function configure()
{
$this->widgetSchema['name'] = new sfWidgetFormInput();
$this->widgetSchema->setLabel('name', '名前');
$this->validatorSchema['name'] = new sfValidatorStri...
$this->validatorSchema['name']->setMessage('min_leng...
$this->validatorSchema['name']->setOption('min_lengt...
$this->validatorSchema['name']->setOption('required'...
$this->validatorSchema['name']->setMessage('required...
(略)
}
}
- lib/form/MemberForm.class.php
- 派生フォームクラスに、業務に基づいたヴァリデーションや...
** コントローラ [#xda90f6c]
public function executeInput(sfWebRequest $request)
{
$this->form = new MemberForm();
}
public function executeRegister(sfWebRequest $request)
{
$member = $request->getParameter('member');
$this->form->bind($member);
if( $this->form->isValid() === true ){
// $memberをDBに入れる
} else {
$this->getUser()->setAttribute('member_data', $membe...
$this->redirect('entry/input');
}
}
** テンプレート [#hbec0073]
<form action="<?php echo url_for('entry/register') ?>" m...
名前:<?php echo $form['name'] ?><br />
<?php if( $form['name']->hasError() === true ) { ?>
エラー:<?php echo $form['name']->getError() ?><br...
<?php } ?>
<input type="submit" />
</form>
- inputSuccess.php
** ウィジェット・バリデータ [#q69fa0f1]
*** ウィジェット [#kdb4791b]
- http://www.symfony-project.org/forms/1_2/ja/A-Widgets
*** バリデータ [#n41419d6]
- sfValidatorString
- sfValidatorRegex
- sfValidatorEmail
- sfValidatorUrl
- sfValidatorInteger
- sfValidatorNumber
- sfValidatorBoolean
- sfValidatorChoice
- 他
http://www.symfony-project.org/forms/1_2/ja/B-Validators
** 参考 [#x1178737]
- http://www.symfony-project.org/tutorial/1_2/ja/my-first...
- http://www.symfony-project.org/forms/1_2/ja/01-Form-Cre...
ページ名: