本文整理汇总了PHP中Nette\Forms\Form::addContainer方法的典型用法代码示例。如果您正苦于以下问题:PHP Form::addContainer方法的具体用法?PHP Form::addContainer怎么用?PHP Form::addContainer使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nette\Forms\Form
的用法示例。
在下文中一共展示了Form::addContainer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: emailTemplate
/**
* Email template settings in adin
*
* @param null $defaults
* @return Nette\Forms\Form
*/
public static function emailTemplate($defaults = NULL)
{
$form = new Form('adminEmailTemplate');
// Email template
$form->addGroup('E-mail template');
$formEmail = $form->addContainer('emailType');
$formEmail->addSelect('source', 'E-mail type', array('HTML', 'Plain Text'));
$formEmail->addSelect('type', 'E-mail digest type', array('Short Excerpt.', 'Short Excerpt with Featured Image', 'Whole Post (not recommended)'));
// Design of e-mail
$form->addGroup('E-mail design');
$formDesign = $form->addContainer('emailDesign');
$formDesign->addText('colourBodyBg', 'E-mail background colour')->setType('color')->setOption('description', 'Default: #ececec')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Background colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
$formDesign->addText('colourBg', 'Header background colour')->setType('color')->setOption('description', 'Default: #f5f5f5')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Background colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
$formDesign->addText('colourTitle', 'Header title colour')->setType('color')->setOption('description', 'Default: #000000')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Title colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
$formDesign->addText('colourLinks', 'Links colour')->setType('color')->setOption('description', 'Default: #000000')->addCondition(Form::FILLED)->addRule(Form::PATTERN, 'Link colour must be a valid hex code.', '^#?([a-fA-F0-9]{6}|[a-fA-F0-9]{3})$');
// Social links
$form->addGroup('Social Media Links');
$formSocial = $form->addContainer('social');
foreach (Settings::getSocialServices() as $key => $value) {
$formSocial->addText($key, $value . ' profile URL')->addCondition(Form::FILLED)->addRule(Form::URL, $value . ' profile URL, must be a valid URL.');
}
// Submit
$form->addSubmit('submit', 'Save')->setAttribute('class', 'button-primary');
// set dafaults
if ($defaults) {
$form->setDefaults($defaults);
}
return $form;
}
示例2:
die('Install packages using `composer update --dev`');
}
use Nette\Forms\Form;
use Tracy\Debugger;
use Tracy\Dumper;
Debugger::enable();
$form = new Form;
// group First person
$form->addGroup('First person');
$first = $form->addContainer('first');
$first->addText('name', 'Your name:');
$first->addText('email', 'Email:');
$first->addText('street', 'Street:');
$first->addText('city', 'City:');
// group Second person
$form->addGroup('Second person');
$second = $form->addContainer('second');
$second->addText('name', 'Your name:');
$second->addText('email', 'Email:');
$second->addText('street', 'Street:');
$second->addText('city', 'City:');
// group for button
示例3: Form
<?php
// Latte: {$Forms[contact]}
use Nette\Forms\Form;
$form = new Form();
$form->setRenderer(new \Nextras\Forms\Rendering\Bs3FormRenderer());
$form->addProtection('Detected robot activity.');
$c = $form->addContainer('frm');
$c->addText('email', 'Your email')->addCondition($form::FILLED)->addRule($form::EMAIL, 'Please fill in a valid e-mail address.');
$c->addTextarea('message', 'Message')->setRequired('Please fill in a message.');
$c->addSubmit('send', 'Send');
if (isFormValid($form, __FILE__)) {
dump($c->getValues());
}
return $form;
示例4: createForm
function createForm()
{
$form = new Form();
$form->addProtection('Detected robot activity.');
$c = $form->addContainer('frm');
$deliveryConstraints = $this->getDeliveryConstraints();
if ($deliveryConstraints) {
$c->addRadiolist(self::OPTION_DELIVERY, self::OPTION_DELIVERY, array_combine($deliveryConstraints, $deliveryConstraints))->setRequired()->setDefaultValue($this->getDelivery());
}
$paymentConstraints = $this->getPaymentConstraints();
if ($paymentConstraints) {
$c->addRadiolist(self::OPTION_PAYMENT, self::OPTION_PAYMENT, array_combine($paymentConstraints, $paymentConstraints))->setRequired()->setDefaultValue($this->getPayment());
}
$c->addText('delivery_name', 'delivery_name')->setRequired();
$c->addTextarea('delivery_address', 'delivery_address');
$c->addText('payment_name', 'payment_name');
$c->addTextarea('payment_address', 'payment_address');
$c->addText('payment_ic', 'payment_ic');
$c->addText('payment_dic', 'payment_dic');
if (!empty($this->config['allow_note'])) {
$c->addTextarea('note', 'note');
}
$c->setDefaults($this->getOptions());
$c->addSubmit('send', 'Save order');
if (isFormValid($form, 'submit-order')) {
$vals = $c->values;
if ($vals[self::OPTION_PAYMENT]) {
$this->setPayment($vals[self::OPTION_PAYMENT]);
}
if ($vals[self::OPTION_DELIVERY]) {
$this->setDelivery($vals[self::OPTION_DELIVERY]);
}
$this->setOptions((array) $vals + $this->getOptions());
wp_redirect('?');
}
return $form;
}
示例5: array
/**
* Nette\Forms naming containers example.
*
* - using naming containers
*/
require_once __DIR__ . '/../../Nette/loader.php';
use Nette\Forms\Form, Nette\Debug;
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 First person
$form->addGroup('First person');
$sub = $form->addContainer('first');
$sub->addText('name', 'Your name:');
$sub->addText('email', 'E-mail:');
$sub->addText('street', 'Street:');
$sub->addText('city', 'City:');
$sub->addSelect('country', 'Country:', $countries);
// group Second person
$form->addGroup('Second person');
$sub = $form->addContainer('second');
$sub->addText('name', 'Your name:');
$sub->addText('email', 'E-mail:');
$sub->addText('street', 'Street:');
$sub->addText('city', 'City:');
$sub->addSelect('country', 'Country:', $countries);
// group for buttons
$form->addGroup();