本文整理汇总了PHP中Nette\Forms\Form::addRadioList方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addRadioList方法的具体用法?PHP Form::addRadioList怎么用?PHP Form::addRadioList使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::addRadioList方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setupForm
protected function setupForm(Form $form)
{
$uniqueValidator = new UniqueValidator($this->database->table($this->table), $this->getId());
$form->addText('name', 'Name')->setRequired();
$form->addText('email', 'Email')->setRequired()->setType('email')->addRule(Form::EMAIL)->addRule($uniqueValidator->validate, 'This email is already registered.');
$form->addPassword('password', 'Password')->addCondition(Form::FILLED)->addRule(Form::MIN_LENGTH, NULL, 6);
$roles = array_combine($this->roles, $this->roles);
$form->addRadioList('role', 'Role', $roles)->setRequired();
$form->addSubmit('submit', 'Submit');
$this->onPreSave[] = $this->hashPassword;
}
示例2: array
'US' => 'United States',
'?' => 'other',
);
$sex = array(
'm' => 'male',
'f' => 'female',
);
// Step 1: Define form
$form = new Form;
$form->addText('name');
$form->addText('age');
$form->addRadioList('gender', NULL, $sex);
$form->addText('email')->setEmptyValue('@');
$form->addCheckbox('send');
$form->addText('street');
$form->addText('city');
$form->addSelect('country', NULL, $countries)->setPrompt('Select your country');
$form->addPassword('password');
$form->addPassword('password2');
$form->addUpload('avatar');
$form->addHidden('userid');
$form->addTextArea('note');
$form->addSubmit('submit');
示例3: die
* Nette Forms basic example.
*/
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
use Nette\Utils\Html;
Debugger::enable();
$form = new Form();
// group Personal data
$form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
$form->addText('name', 'Your name:')->setRequired('Enter your name');
$form->addText('age', 'Your age:')->setRequired('Enter your age')->addRule($form::INTEGER, 'Age must be numeric value')->addRule($form::RANGE, 'Age must be in range from %d to %d', array(10, 100));
$form->addRadioList('gender', 'Your gender:', array('m' => 'male', 'f' => 'female'));
$form->addCheckboxList('colors', 'Favorite colors:', array('r' => 'red', 'g' => 'green', 'b' => 'blue'));
$form->addText('email', 'Email:')->setEmptyValue('@')->addCondition($form::FILLED)->addRule($form::EMAIL, 'Incorrect email address');
// ... then check email
// group Shipping address
$form->addGroup('Shipping address')->setOption('embedNext', TRUE);
$form->addCheckbox('send', 'Ship to address')->addCondition($form::FILLED)->toggle('sendBox');
// toggle div #sendBox
// subgroup
$form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
$form->addText('street', 'Street:');
$form->addText('city', 'City:')->addConditionOn($form['send'], $form::FILLED)->setRequired('Enter your shipping address');
$countries = array('World' => array('bu' => 'Buranda', 'qu' => 'Qumran', 'st' => 'Saint Georges Island'), '?' => 'other');
$form->addSelect('country', 'Country:', $countries)->setPrompt('Select your country')->addConditionOn($form['send'], $form::FILLED)->setRequired('Select your country');
// group Your account
$form->addGroup('Your account');
示例4: Form
$form = new Form();
// setup custom rendering
$renderer = $form->getRenderer();
$renderer->wrappers['form']['container'] = Html::el('div')->id('form');
$renderer->wrappers['group']['container'] = NULL;
$renderer->wrappers['group']['label'] = 'h3';
$renderer->wrappers['pair']['container'] = NULL;
$renderer->wrappers['controls']['container'] = 'dl';
$renderer->wrappers['control']['container'] = 'dd';
$renderer->wrappers['control']['.odd'] = 'odd';
$renderer->wrappers['label']['container'] = 'dt';
$renderer->wrappers['label']['suffix'] = ':';
$renderer->wrappers['control']['requiredsuffix'] = " •";
$form->addGroup('Personal data');
$form->addText('name', 'Your name')->setRequired('Enter your name');
$form->addRadioList('gender', 'Your gender', array('m' => Html::el('option', 'male')->style('color: #248bd3'), 'f' => Html::el('option', 'female')->style('color: #e948d4')));
$form->addSelect('country', 'Country', array('Buranda', 'Qumran', 'Saint Georges Island'));
$form->addCheckbox('send', 'Ship to address');
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password');
$form->addUpload('avatar', 'Picture');
$form->addTextArea('note', 'Comment');
$form->addGroup();
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
?>
<!DOCTYPE html>
示例5: array
* - form definition using fluent interfaces
* - form groups usage
* - default rendering
*/
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug, Nette\Web\Html;
Debug::enable();
$countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'SK' => 'Slovakia', 'GB' => 'United Kingdom'), 'CA' => 'Canada', 'US' => 'United States', '?' => 'other');
$sex = array('m' => 'male', 'f' => 'female');
// Step 1: Define form with validation rules
$form = new Form();
// group Personal data
$form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
$form->addText('name', 'Your name:')->addRule(Form::FILLED, 'Enter your name');
$form->addText('age', 'Your age:')->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %d to %d', array(10, 100));
$form->addRadioList('gender', 'Your gender:', $sex);
$form->addText('email', 'E-mail:')->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
// ... then check email
// group Shipping address
$form->addGroup('Shipping address')->setOption('embedNext', TRUE);
$form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
// toggle div #sendBox
// subgroup
$form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
$form->addText('street', 'Street:');
$form->addText('city', 'City:')->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
$form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
// group Your account
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password:')->addRule(Form::FILLED, 'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
$form->addPassword('password2', 'Reenter password:')->addConditionOn($form['password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
示例6: die
<?php
/**
* Nette Forms manual form rendering.
*/
if (@(!(include __DIR__ . '/../../Nette/loader.php'))) {
die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form();
$form->addText('name')->setRequired('Enter your name');
$form->addText('age')->setRequired('Enter your age');
$form->addRadioList('gender', NULL, array('m' => 'male', 'f' => 'female'));
$form->addText('email')->addCondition($form::FILLED)->addRule($form::EMAIL, 'Incorrect email address');
$form->addSubmit('submit');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Nette Forms manual form rendering</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />
<script src="https://nette.github.io/resources/js/netteForms.js"></script>
示例7: die
<?php
/**
* Nette Forms & Bootstap 3 rendering example.
*/
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form();
$form->addGroup('Personal data');
$form->addText('name', 'Your name')->setRequired('Enter your name');
$form->addRadioList('gender', 'Your gender', ['male', 'female']);
$form->addCheckboxList('colors', 'Favorite colors:', ['red', 'green', 'blue']);
$form->addSelect('country', 'Country', ['Buranda', 'Qumran', 'Saint Georges Island']);
$form->addCheckbox('send', 'Ship to address');
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password');
$form->addUpload('avatar', 'Picture');
$form->addTextArea('note', 'Comment');
$form->addGroup();
$form->addSubmit('submit', 'Send');
$form->addSubmit('cancel', 'Cancel');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
示例8: array
use Nette\Forms\Form;
use Nette\Forms\Controls;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form;
$form->addGroup('Personal data');
$form->addText('name', 'Your name')
->setRequired('Enter your name');
$form->addRadioList('gender', 'Your gender', array(
'male', 'female',
));
$form->addCheckboxList('colors', 'Favorite colors:', array(
'red', 'green', 'blue',
));
$form->addSelect('country', 'Country', array(
'Buranda', 'Qumran', 'Saint Georges Island',
));
$form->addCheckbox('send', 'Ship to address');
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password');
$form->addUpload('avatar', 'Picture');
示例9: die
<?php
/**
* Nette Forms manual form rendering.
*/
if (@(!(include __DIR__ . '/../vendor/autoload.php'))) {
die('Install packages using `composer install`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form();
$form->addText('name')->setRequired('Enter your name');
$form->addText('age')->setRequired('Enter your age');
$form->addRadioList('gender', NULL, ['m' => 'male', 'f' => 'female']);
$form->addText('email')->addCondition($form::FILLED)->addRule($form::EMAIL, 'Incorrect email address');
$form->addSubmit('submit');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Nette Forms manual form rendering</title>
<link rel="stylesheet" media="screen" href="assets/style.css" />
<script src="https://nette.github.io/resources/js/netteForms.js"></script>
示例10: Form
$form = new Form();
// setup custom rendering
$renderer = $form->getRenderer();
$renderer->wrappers['form']['container'] = Html::el('div')->id('form');
$renderer->wrappers['group']['container'] = NULL;
$renderer->wrappers['group']['label'] = 'h3';
$renderer->wrappers['pair']['container'] = NULL;
$renderer->wrappers['controls']['container'] = 'dl';
$renderer->wrappers['control']['container'] = 'dd';
$renderer->wrappers['control']['.odd'] = 'odd';
$renderer->wrappers['label']['container'] = 'dt';
$renderer->wrappers['label']['suffix'] = ':';
$renderer->wrappers['control']['requiredsuffix'] = " •";
$form->addGroup('Personal data');
$form->addText('name', 'Your name')->setRequired('Enter your name');
$form->addRadioList('gender', 'Your gender', ['m' => Html::el('span', 'male')->style('color: #248bd3'), 'f' => Html::el('span', 'female')->style('color: #e948d4')]);
$form->addSelect('country', 'Country', ['Buranda', 'Qumran', 'Saint Georges Island']);
$form->addCheckbox('send', 'Ship to address');
$form->addGroup('Your account');
$form->addPassword('password', 'Choose password');
$form->addUpload('avatar', 'Picture');
$form->addTextArea('note', 'Comment');
$form->addGroup();
$form->addSubmit('submit', 'Send');
if ($form->isSuccess()) {
echo '<h2>Form was submitted and successfully validated</h2>';
Dumper::dump($form->getValues());
exit;
}
?>
<!DOCTYPE html>