本文整理汇总了PHP中Symfony\Component\Form\FormBuilder::add方法的典型用法代码示例。如果您正苦于以下问题:PHP FormBuilder::add方法的具体用法?PHP FormBuilder::add怎么用?PHP FormBuilder::add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\Form\FormBuilder
的用法示例。
在下文中一共展示了FormBuilder::add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('product');
$builder->add('price');
$builder->add('start_date');
$builder->add('expire_date');
}
示例2: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('lastname', 'text', array('label' => 'Lastname', 'required' => false));
$builder->add('firstname', 'text', array('label' => 'Firstname', 'required' => false));
$builder->add('username', 'text', array('label' => 'Username', 'required' => false));
$builder->add('group', 'entity', array('class' => 'CuteFlow\\CoreBundle\\Entity\\UserGroup', 'required' => false, 'label' => 'Usergroup'));
}
示例3: setRequestToken
protected function setRequestToken()
{
if (!\Config::get('disableRefererCheck')) {
$token = \RequestToken::get();
$this->builder->add('REQUEST_TOKEN', 'hidden', array('data' => $token));
}
}
示例4: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('account');
$builder->add('user', 'entity', array('class' => 'Club\\UserBundle\\Entity\\User', 'required' => false));
$builder->add('value');
$builder->add('note');
}
示例5: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$hourOptions = $minuteOptions = $secondOptions = array();
$parts = array('hour', 'minute');
if ($options['widget'] === 'choice') {
$hourOptions['choice_list'] = new PaddedChoiceList(array_combine($options['hours'], $options['hours']), 2, '0', STR_PAD_LEFT);
$minuteOptions['choice_list'] = new PaddedChoiceList(array_combine($options['minutes'], $options['minutes']), 2, '0', STR_PAD_LEFT);
if ($options['with_seconds']) {
$secondOptions['choice_list'] = new PaddedChoiceList(array_combine($options['seconds'], $options['seconds']), 2, '0', STR_PAD_LEFT);
}
}
$builder->add('hour', $options['widget'], $hourOptions)->add('minute', $options['widget'], $minuteOptions);
if ($options['with_seconds']) {
$parts[] = 'second';
$builder->add('second', $options['widget'], $secondOptions);
}
if ($options['input'] === 'string') {
$builder->appendNormTransformer(new ReversedTransformer(new DateTimeToStringTransformer($options['data_timezone'], $options['data_timezone'], 'H:i:s')));
} else {
if ($options['input'] === 'timestamp') {
$builder->appendNormTransformer(new ReversedTransformer(new DateTimeToTimestampTransformer($options['data_timezone'], $options['data_timezone'])));
} else {
if ($options['input'] === 'array') {
$builder->appendNormTransformer(new ReversedTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['data_timezone'], $parts)));
}
}
}
$builder->appendClientTransformer(new DateTimeToArrayTransformer($options['data_timezone'], $options['user_timezone'], $parts, $options['widget'] === 'text'))->setAttribute('widget', $options['widget'])->setAttribute('with_seconds', $options['with_seconds']);
}
示例6: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('defaultLanguage', 'choice', array('label' => 'Default language', 'choices' => array('de' => 'Deutsch', 'en' => "English")));
$builder->add('defaultTheme', 'choice', array('choices' => array('basecamp' => 'Basecamp', 'modulaMartini' => 'Modula Martini', 'modulaMojito' => 'Modula Mojito'), 'label' => 'Default theme'));
$builder->add('useGravatar', 'checkbox', array('label' => 'Use Gravatar user icons'));
$builder->add('userFormat', 'choice', array('choices' => array('username' => 'jdoe', 'fullname_fl' => 'John Doe', 'fullname_lf' => 'Doe, John', 'firstname' => 'John', 'lastname' => 'Doe'), 'required' => true, 'label' => 'Userformat'));
}
示例7: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('senderEmail');
$builder->add('senderName');
$builder->add('subject');
$builder->add('message', 'textarea');
}
示例8: buildForm
public function buildForm(FormBuilder $builder, array $opciones)
{
$builder->add('nombreOpcion', 'text');
$builder->add('descripcionOpcion', 'text');
$builder->add('enlace', 'text');
$builder->add('idOpcionSistema2', 'integer');
}
示例9: buildForm
/**
* Build form
*
* @param FormBuilder $builder
* @param array $options
*/
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('title')->add('description')->add('keywords')->add('template', 'choice', array('choices' => $this->getTemplates()))->add('link')->add('is_published');
if ($options['data']->getId() !== 1) {
$builder->add('parent');
}
}
示例10: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('lastname', 'text', array('label' => 'rtxlabs.user.label.lastname', 'required' => false));
$builder->add('firstname', 'text', array('label' => 'rtxlabs.user.label.firstname', 'required' => false));
$builder->add('username', 'text', array('label' => 'rtxlabs.user.label.username', 'required' => false));
$builder->add('personnelNumber', 'text', array('label' => 'rtxlabs.user.label.personnel_number', 'required' => false));
}
示例11: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('street');
$builder->add('zipcode');
$builder->add('city');
$builder->add('country');
}
示例12: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('firstname', 'text', array('label' => 'form.label.firstname'))->add('lastname', 'text', array('label' => 'form.label.lastname'))->add('states', 'choice', array('choices' => array('foo' => 'bar'), 'empty_value' => 'form.states.empty_value'))->add('countries', 'choice', array('empty_value' => false))->add('password', 'repeated', array('first_options' => array('label' => 'form.label.password'), 'second_options' => array('label' => 'form.label.password_repeated'), 'invalid_message' => 'form.error.password_mismatch'))->add('street', 'text', array('label' => 'form.label.street', 'translation_domain' => 'address'))->add('zip', 'text', array('label' => 'form.label.zip', 'translation_domain' => 'address'))->add('field_with_placeholder', 'text', array('label' => 'field.with.placeholder', 'attr' => array('placeholder' => 'form.placeholder.text')))->add('field_without_label', 'text', array('label' => false, 'attr' => array('placeholder' => 'form.placeholder.text.but.no.label')));
$child = $builder->create('created', 'text', array('label' => 'form.label.created'));
$builder->add('dueDate', 'date', array('empty_value' => array('year' => 'form.dueDate.empty.year', 'month' => 'form.dueDate.empty.month', 'day' => 'form.dueDate.empty.day')));
$builder->add('field_with_ignored_label', 'text', array('label' => 'form.ignored'));
}
示例13: buildForm
/**
* Configures a Comment form.
*
* @param FormBuilder $builder
* @param array $options
*/
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('message', 'textarea');
if (!$this->securityContext->isGranted('IS_AUTHENTICATED_REMEMBERED')) {
$builder->add('authorName', 'text');
}
}
示例14: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
if (!isset($options['currency'])) {
throw new \InvalidArgumentException(sprintf('The option "currency" must be given for form type "%s".', $this->getName()));
}
if (!isset($options['amount'])) {
throw new \InvalidArgumentException(sprintf('The option "amount" must be given for form type "%s".', $this->getName()));
}
$allowAllMethods = !isset($options['allowed_methods']);
$options['available_methods'] = array();
foreach ($this->paymentMethods as $method) {
if (!$allowAllMethods && !in_array($method, $options['allowed_methods'], true)) {
continue;
}
$options['available_methods'][] = $method;
}
if (!$options['available_methods']) {
throw new \RuntimeException(sprintf('You have not selected any payment methods. Available methods: "%s"', implode(', ', $this->paymentMethods)));
}
$builder->add('method', 'choice', array('choices' => $this->buildChoices($options['available_methods']), 'expanded' => true));
foreach ($options['available_methods'] as $method) {
$methodOptions = isset($options['method_options'][$method]) ? $options['method_options'] : array();
$builder->add('data_' . $method, $method, $methodOptions);
}
$self = $this;
$builder->addValidator(new CallbackValidator(function ($form) use($self, $options) {
$self->validate($form, $options);
}));
$builder->appendNormTransformer(new CallbackTransformer(function ($data) use($self, $options) {
return $self->transform($data, $options);
}, function ($data) use($self, $options) {
return $self->reverseTransform($data, $options);
}));
}
示例15: buildForm
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('name');
$builder->add('email', 'email');
$builder->add('subject');
$builder->add('body', 'textarea');
}