本文整理汇总了PHP中sfForm::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP sfForm::setup方法的具体用法?PHP sfForm::setup怎么用?PHP sfForm::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sfForm
的用法示例。
在下文中一共展示了sfForm::setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setup
public function setup()
{
parent::setup();
$years = range(date('Y'), date('Y') + 10);
$year_range = array();
foreach ($years as $key => $value) {
$year_range[$value] = $value;
}
// Credit card input fields
$this->widgetSchema['cc_type'] = new sfWidgetFormSelect(array('choices' => sfConfig::get('app_rt_shop_payment_methods', array('Mastercard' => 'Mastercard', 'Visa' => 'Visa'))));
$this->widgetSchema['cc_number'] = new sfWidgetFormInput(array(), array('class' => 'text'));
$this->widgetSchema['cc_name'] = new sfWidgetFormInput(array(), array('class' => 'text'));
$this->widgetSchema['cc_expire'] = new sfWidgetFormDate(array('format' => '%month%/%year%', 'years' => $year_range), array('style' => 'width:60px'));
$this->widgetSchema['cc_verification'] = new sfWidgetFormInput(array(), array('size' => 4, 'maxlength' => 4, 'class' => 'medium text'));
// Add labels
$this->widgetSchema->setLabel('cc_type', "Card type:");
$this->widgetSchema->setLabel('cc_name', "Name on Card:");
$this->widgetSchema->setLabel('cc_number', "Credit Card number:");
$this->widgetSchema->setLabel('cc_expire', "Expiry Date:");
$this->widgetSchema->setLabel('cc_verification', "Verification Number:");
// Help text
$this->widgetSchema->setHelp('cc_number', 'Example: 4100 0000 0000 0000.');
$this->widgetSchema->setHelp('cc_verification', 'The verification Number is a three or four-digit number on the back or front of your credit card.');
// Validators
$this->setValidators(array('cc_type' => new sfValidatorString(array('required' => true), array('required' => 'Please provide a credit card type.')), 'cc_name' => new sfValidatorString(array('max_length' => 100, 'required' => true), array('required' => 'Please enter the name as shown on the credit card.')), 'cc_number' => new sfValidatorString(array('required' => true), array('required' => 'Please provide a credit card number.')), 'cc_expire' => new sfValidatorPass(), 'cc_verification' => new sfValidatorString(array('min_length' => 3, 'max_length' => 4, 'required' => true), array('required' => 'Please provide a verification number.'))));
$this->widgetSchema->setNameFormat('rt_shop_order_creditcard[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->validatorSchema->setPostValidator(new rtShopCreditCardValidator());
$this->getWidgetSchema()->setFormFormatterName(sfConfig::get('app_rt_public_form_formatter_name', 'RtList'));
}
示例2: setUp
public function setUp()
{
$this->setWidgets(array('url_depart' => new sfWidgetFormInput(), 'navigateur' => new sfWidgetFormSelect(array('choices' => self::$navigateurs)), 'version' => new sfWidgetFormSelect(array('choices' => self::$versions)), 'robot' => new sfWidgetFormSelect(array('choices' => self::$robot)), 'vitesse_jeu' => new sfWidgetFormSelect(array('choices' => self::$vitesse_jeu)), 'environnement' => new sfWidgetFormInput()));
$this->setValidators(array('url_depart' => new sfValidatorUrl(), 'navigateur' => new sfValidatorChoice(array('choices' => array_keys(self::$navigateurs))), 'version' => new sfValidatorChoice(array('choices' => array_keys(self::$versions))), 'robot' => new sfValidatorChoice(array('choices' => array_keys(self::$robot))), 'vitess_jeu' => new sfValidatorString(array('min_length' => 4), array('required' => 'Le champ message est obligatoire.'))));
$this->widgetSchema->setNameFormat('playOnRobot[%s]');
parent::setup();
}
示例3: setup
public function setup()
{
$this->setValidatorSchema(new sfValidatorSchema(array('id' => new sfValidatorPass(), 'page' => new sfValidatorString(array('max_length' => 255)), 'module' => new sfValidatorString(array('max_length' => 128)), 'action' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'credential' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'catch_all' => new sfValidatorPass(), 'parent' => new sfValidatorPass(), 'order' => new sfValidatorPass(), 'order_option' => new sfValidatorPass())));
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
$this->setDefault('order_option', 'below');
parent::setup();
}
示例4: setup
public function setup()
{
parent::setup();
$this->setWidgets(array('username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInput(array('type' => 'password')), 'remember' => new sfWidgetFormInputCheckbox()));
$this->setValidators(array('username' => new sfValidatorString(), 'password' => new sfValidatorString(), 'remember' => new sfValidatorBoolean()));
$this->validatorSchema->setPostValidator(new sfGuardValidatorUser());
$this->widgetSchema->setNameFormat('signin[%s]');
}
示例5: setup
public function setup()
{
$this->setWidgets(array('fields' => new sfWidgetFormChoice(array('multiple' => true, 'expanded' => true, 'choices' => $this->options['fields']))));
$this->setValidators(array('fields' => new sfValidatorChoice(array('multiple' => true, 'choices' => array_keys($this->options['fields']), 'required' => true))));
$this->widgetSchema->setNameFormat('csv[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例6: setup
public function setup()
{
$this->setWidgetSchema(new sfWidgetFormSchema(array('page' => new sfWidgetFormInput(), 'module' => new sfWidgetFormInput(), 'action' => new sfWidgetFormInput(), 'credential' => new sfWidgetFormInput(), 'catch_all' => new sfWidgetFormInputCheckbox())));
$this->setValidatorSchema(new sfValidatorSchema(array('page' => new sfValidatorString(array('max_length' => 255)), 'module' => new sfValidatorString(array('max_length' => 128)), 'action' => new sfValidatorString(array('max_length' => 128)), 'credential' => new sfValidatorString(array('max_length' => 128, 'required' => false)), 'catch_all' => new sfValidatorPass())));
$this->widgetSchema->setNameFormat('sfbreadnavedithomeform[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例7: configure
public function configure()
{
$this->setWidgets(array('email' => new sfWidgetFormInput()));
$this->widgetSchema->setNameFormat('forgotpassword[%s]');
$this->setValidators(array('email' => new sfValidatorEmail(array('required' => true), array('required' => 'Please enter your email'))));
$this->widgetSchema->setNameFormat('forgotpassword[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例8: setup
public function setup()
{
$scopes = sfBreadNavApplicationPeer::getScopeArray();
$this->setWidgetSchema(new sfWidgetFormSchema(array('scope' => new sfWidgetFormSelect(array('choices' => $scopes), array('onchange' => 'scopeform.submit()')))));
$this->setValidatorSchema(new sfValidatorSchema(array('scope' => new sfValidatorPass())));
$this->widgetSchema->setNameFormat('%s');
$this->widgetSchema->setLabel('scope', 'Active Menu');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例9: configure
public function configure()
{
$this->setWidgets(array('captcha' => new sfWidgetFormInput()));
$this->widgetSchema->setLabels(array('captcha' => 'Please copy the security code.'));
$this->setValidators(array('captcha' => new sfValidatorSfCryptoCaptcha(array('required' => true, 'trim' => true), array('wrong_captcha' => 'The code you copied is not valid.', 'required' => 'You did not copy any code. Please copy the code.'))));
$this->widgetSchema->setNameFormat('captcha_demo[%s]');
$this->widgetSchema->setFormFormatterName('table');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例10: setup
public function setup()
{
$options = array('required' => false, 'mime_types' => 'upload_files', 'path' => sfConfig::get('sf_upload_dir'), 'mime_categories' => array('upload_files' => array('image/jpeg', 'image/pjpeg', 'image/png', 'image/x-png', 'image/gif', 'application/msword', 'application/pdf')));
for ($i = 0; $i < 5; $i++) {
$this->widgetSchema["file_" . $i] = new sfWidgetFormInputFile();
$this->validatorSchema["file_" . $i] = new sfValidatorFile($options);
}
$this->widgetSchema->setNameFormat('jobattach[%s]');
parent::setup();
}
示例11: setup
public function setup()
{
parent::setup();
$this->widgetSchema->setFormFormatterName('bootstrap');
$this->widgetSchema->setNameFormat('contact_upload1[%s]');
$this->setWidget('separator', new sfWidgetFormInputText());
$this->setValidator('separator', new sfValidatorString(array('min_length' => 1, 'max_length' => 1)));
$this->getWidgetSchema()->setDefault('separator', ',');
$this->setWidget('file', new sfWidgetFormInputFile());
$this->setValidator('file', new sfValidatorFile(array('required' => true)));
}
示例12: configure
public function configure()
{
$this->setWidgets(array('email' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInputPassword()));
$this->widgetSchema->setNameFormat('login[%s]');
$this->setValidators(array('email' => new sfValidatorString(array('required' => false)), 'password' => new sfValidatorString(array('required' => false))));
$this->widgetSchema->setLabel('email', 'Email Or UserName');
$this->widgetSchema->setLabel('password', 'Password');
$this->widgetSchema->setNameFormat('users[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例13: setUp
public function setUp()
{
// $this->getEmbeddedForm()->
//Récupération des paramètres passés au formulaire
$params = $this->options;
$versions['0'] = null;
foreach ($params['versions'] as $i => $q1) {
$versions[$q1->id] = $q1->libelle . ' ' . $q1->getEiScenario()->nom_scenario;
}
$this->widgetSchema['version'] = new sfWidgetFormChoice(array('choices' => $versions));
$this->validatorSchema['version'] = new sfValidatorChoice(array('required' => true, 'choices' => array_keys($versions)));
$this->widgetSchema->setNameFormat('choiceVersion[%s]');
parent::setup();
}
示例14: configure
public function configure()
{
parent::configure();
$this->setWidgets(array('username' => new sfWidgetFormInput(), 'password' => new sfWidgetFormInputPassword(), 'confirmpassword' => new sfWidgetFormInputPassword(), 'firstname' => new sfWidgetFormInput(), 'lastname' => new sfWidgetFormInput(), 'email' => new sfWidgetFormInput()));
$this->widgetSchema->setLabel('username', 'UserName');
$this->widgetSchema->setLabel('password', 'Password');
$this->widgetSchema->setLabel('confirmpassword', 'Confirm Password');
$this->widgetSchema->setLabel('firstname', 'First Name');
$this->widgetSchema->setLabel('lastname', 'Last Name');
$this->widgetSchema->setLabel('email', 'Email');
$this->setValidators(array('username' => new sfValidatorString(array('required' => true)), 'password' => new sfValidatorString(array('required' => true)), 'confirmpassword' => new sfValidatorString(array('required' => true)), 'firstname' => new sfValidatorString(array('required' => true)), 'lastname' => new sfValidatorString(array('required' => true)), 'email' => new sfValidatorEmail()));
$this->mergePostValidator(new sfValidatorSchemaCompare('password', sfValidatorSchemaCompare::EQUAL, 'confirmpassword', array(), array('invalid' => 'The two passwords must be the same.')));
$this->widgetSchema->setNameFormat('newuser[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
parent::setup();
}
示例15: setup
public function setup()
{
parent::setup();
$years = range(date('Y') - 15, date('Y'));
$options = array('format' => '%day% / %month% / %year%', 'years' => array_combine($years, $years));
// Widgets
$this->widgetSchema['date_from'] = new sfWidgetFormJQueryDate(array('config' => '{}', 'date_widget' => new sfWidgetFormDate($options)));
$this->widgetSchema['date_to'] = new sfWidgetFormJQueryDate(array('config' => '{}', 'date_widget' => new sfWidgetFormDate($options)));
// Add labels
$this->widgetSchema->setLabel('date_from', "Date From:");
$this->widgetSchema->setLabel('date_to', "Date To:");
// Validators
$this->setValidators(array('date_from' => new sfValidatorDate(array('required' => false), array()), 'date_to' => new sfValidatorDate(array('required' => false), array())));
$this->widgetSchema->setNameFormat('rt_shop_order_report[%s]');
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);
}