作者:NicolasBade
项目:symfon
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['type'] === 'string') {
$builder->appendNormTransformer(new ReversedTransformer(new FileToStringTransformer()));
}
$builder->appendNormTransformer(new FileToArrayTransformer())->add('file', 'field');
}
作者:hafeez300
项目:liches
/**
* 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');
}
}
作者:Silweret
项目:Syliu
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type(BuildRuleFormSubscriber::class))->willReturn($builder);
$this->buildForm($builder, array());
}
作者:lingod
项目:Syliu
function it_builds_form_with_proper_fields(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\TaxonomyBundle\\Form\\EventListener\\BuildTaxonFormSubscriber'))->willReturn($builder);
$builder->add('translations', 'a2lix_translationsForms', Argument::any())->willReturn($builder);
$this->buildForm($builder, array());
}
作者:GabLeRou
项目:JMSTranslationBundl
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'));
}
作者:rfc148
项目:blo
public function buildForm(FormBuilder $builder, array $options)
{
if ($options['type'] === 'string') {
$builder->appendNormTransformer(new ReversedTransformer(new FileToStringTransformer()));
}
$builder->appendNormTransformer(new FileToArrayTransformer())->addEventSubscriber(new FixFileUploadListener($this->storage), 10)->add('file', 'field')->add('token', 'hidden')->add('name', 'hidden')->add('originalName', 'hidden');
}
作者:hbocanegr
项目:esteti
public function buildForm(FormBuilder $builder, array $options)
{
$id = $this->options['user'];
$builder->add('sede', 'entity', array('class' => 'dlaser\\ParametrizarBundle\\Entity\\Sede', 'property_path' => false, 'empty_value' => 'Seleccione una sede', 'query_builder' => function (EntityRepository $er) use($id) {
return $er->createQueryBuilder('s', 'u')->leftJoin("s.usuario", "u")->where("u.id = :id")->setParameter('id', $id);
}));
}
作者:nany
项目:Syliu
function it_should_add_rule_event_subscriber(FormBuilder $builder, FormFactoryInterface $factory)
{
$builder->getFormFactory()->willReturn($factory);
$builder->add(Argument::any(), Argument::cetera())->willReturn($builder);
$builder->addEventSubscriber(Argument::type('Sylius\\Bundle\\ShippingBundle\\Form\\EventListener\\BuildRuleFormSubscriber'))->willReturn($builder);
$this->buildForm($builder, array());
}
作者:Neto201
项目:sidpla-isr
public function buildForm(FormBuilder $builder, array $opciones)
{
$builder->add('nombreOpcion', 'text');
$builder->add('descripcionOpcion', 'text');
$builder->add('enlace', 'text');
$builder->add('idOpcionSistema2', 'integer');
}
作者:nyroDe
项目:NyroCmsBundl
protected function translationFormClb($action, $row, \Symfony\Component\Form\FormBuilder $form)
{
if (count($this->translationFields)) {
$langs = $this->get('nyrocms')->getLocaleNames($row);
$defaultLocale = $this->get('nyrocms')->getDefaultLocale($row);
unset($langs[$defaultLocale]);
$this->translations = array();
foreach ($row->getTranslations() as $tr) {
if (!isset($this->translations[$tr->getLocale()])) {
$this->translations[$tr->getLocale()] = array();
}
$this->translations[$tr->getLocale()][$tr->getField()] = $tr;
}
/* @var $form \Ivory\OrderedForm\Builder\OrderedFormBuilder */
$propertyAccess = PropertyAccess::createPropertyAccessor();
foreach ($langs as $lg => $lang) {
foreach ($this->translationFields as $field => $options) {
$type = $options['type'];
unset($options['type']);
$fieldName = 'lang_' . $lg . '_' . $field;
if (isset($options['required']) && $options['required']) {
$options['constraints'] = array(new Constraints\NotBlank());
}
$form->add($fieldName, $type, array_merge(array('label' => $this->trans('admin.' . $this->translationPrefix . '.' . $field) . ' ' . strtoupper($lg), 'mapped' => false, 'data' => isset($this->translations[$lg]) && isset($this->translations[$lg][$field]) ? $this->translations[$lg][$field]->getContent() : $propertyAccess->getValue($row, $field), 'position' => array('after' => $field)), $options));
}
}
}
}
作者:hbocanegr
项目:esteti
public function buildForm(FormBuilder $builder, array $options)
{
$id = $this->options['cie'];
$builder->add('fecha', 'datetime', array('read_only' => true))->add('cie', 'entity', array('class' => 'dlaser\\HcBundle\\Entity\\Cie', 'query_builder' => function (EntityRepository $er) use($id) {
return $er->createQueryBuilder('c', 'hc')->leftJoin("c.hc", "hc")->where("hc.id = :id")->setParameter('id', $id);
}))->add('resumen_hc', 'textarea', array('label' => 'Resumen HC'))->add('pos_utilizado', 'text', array('required' => false, 'label' => 'Pos utilizado'))->add('pos_dosis', 'integer', array('required' => false, 'label' => 'Pos dosis'))->add('pos_tiempo', 'integer', array('required' => false, 'label' => 'Pos tiempo'))->add('pos_posologia', 'text', array('required' => false, 'label' => 'Pos posologia'))->add('pos_respuesta', 'textarea', array('required' => false, 'label' => 'Pos respuesta'))->add('nopos_nota', 'textarea', array('label' => 'Justificación No POS *'))->add('nopos_efectos', 'textarea', array('label' => 'Efectos Adversos del No POS *'));
}
作者:r4cke
项目:lowb
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
$configs = array_replace($this->options, $options['configs']);
$sizeLimit = 2;
$fileDesc = '';
$fileExt = '';
$fileMeta = new Upload();
if (true === isset($configs['multi']) && $configs['multi']) {
$options['multiple'] = true;
}
if (true === $options['multiple']) {
$configs['multi'] = true;
}
if (!isset($options['sizeLimit'])) {
$max_upload = (int) ini_get('upload_max_filesize');
$sizeLimit = $max_upload * 1000000;
} else {
$sizeLimit = $options['sizeLimit'];
}
if (!isset($options['fileDesc'])) {
$fileDesc = 'Tous les fichiers';
} else {
$fileDesc = $options['fileDesc'];
}
if (!isset($options['fileExt'])) {
$fileExt = '*.*';
} else {
$fileExt = $options['fileExt'];
}
$builder->addEventSubscriber(new FileListener($this->rootDir, $options['multiple'], $this->em))->setAttribute('configs', $configs)->setAttribute('rootDir', $this->rootDir)->setAttribute('multiple', $options['multiple'])->setAttribute('session', $this->session)->setAttribute('fileDesc', $fileDesc)->setAttribute('fileExt', $fileExt)->setAttribute('sizeLimit', $sizeLimit)->setAttribute('fileMeta', $fileMeta);
}
作者:alvsgithu
项目:Newscoo
public function let(ArticleService $articleService, AuthorService $authorService, CacheService $cacheService, Container $container, ArticleRepository $articleRepository, LanguageRepository $languageRepository, ArticleTypeRepository $articleTypeRepository, PublicationRepository $publicationRepository, IssueRepository $issueRepository, SectionRepository $sectionRepository, AuthorTypeRepository $authorTypeRepository, EntityManager $entityManager, Request $request, FormFactory $formFactory, FormBuilder $formBuilder, Form $form, FormView $formView, User $user, UserService $userService, Article $article, Publication $publication, ArticleType $articleType, Issue $issue, Section $section, Language $language, Author $author, AuthorType $authorType, AbstractQuery $query, SecurityContext $security, TokenInterface $token, Router $router)
{
$container->get('em')->willReturn($entityManager);
$container->get('request')->willReturn($request);
$container->get('user')->willReturn($userService);
$container->get('form.factory')->willReturn($formFactory);
$container->get('newscoop_newscoop.article_service')->willReturn($articleService);
$container->get('author')->willReturn($authorService);
$container->get('newscoop.cache')->willReturn($cacheService);
$container->get('router')->willReturn($router);
$formBuilder->getForm(Argument::cetera())->willReturn($form);
$formFactory->create(Argument::cetera())->willReturn($form);
$form->createView()->willReturn($formView);
$form->handleRequest(Argument::cetera())->willReturn(true);
$form->isValid()->willReturn(true);
$security->getToken()->willReturn($token);
$container->get('security.context')->willReturn($security);
$container->has('security.context')->willReturn(true);
$this->setContainer($container);
$entityManager->getRepository('Newscoop\\Entity\\Article')->willReturn($articleRepository);
$entityManager->getRepository('Newscoop\\Entity\\Language')->willReturn($languageRepository);
$entityManager->getRepository('Newscoop\\Entity\\ArticleType')->willReturn($articleTypeRepository);
$entityManager->getRepository('Newscoop\\Entity\\Publication')->willReturn($publicationRepository);
$entityManager->getRepository('Newscoop\\Entity\\Issue')->willReturn($issueRepository);
$entityManager->getRepository('Newscoop\\Entity\\Section')->willReturn($sectionRepository);
$entityManager->getRepository('Newscoop\\Entity\\AuthorType')->willReturn($authorTypeRepository);
$articleRepository->getArticle(Argument::cetera())->willReturn($query);
$entityManager->flush(Argument::any())->willReturn(true);
$userService->getCurrentUser()->willReturn($user);
$number = 64;
$language = "en";
}
作者:novate
项目:JMSPaymentCoreBundl
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);
}));
}
作者:raziel05
项目:GenemuFormBundl
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
if (!$options['choice_list']) {
$options['choice_list'] = new AjaxArrayChoiceList($options['choices'], $options['ajax']);
}
$builder->appendClientTransformer(new ChoiceToJsonTransformer($options['choice_list'], $options['widget'], $options['multiple'], $options['ajax'], $options['freeValues']))->setAttribute('choice_list', $options['choice_list'])->setAttribute('widget', $options['widget'])->setAttribute('route_name', $options['route_name'])->setAttribute('freeValues', $options['freeValues']);
}
作者:rtxwebdev
项目:UserBundl
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));
}
作者:ricfran
项目:www.lebowskienico.i
public function buildForm(FormBuilder $builder, array $options)
{
$builder->add('name');
$builder->add('email', 'email');
$builder->add('subject');
$builder->add('body', 'textarea');
}
作者:hollod
项目:clubmaste
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');
}
作者:hotfic
项目:lichess-ol
public function buildForm(FormBuilder $builder, array $options)
{
$languages = $this->languages;
unset($languages['en']);
array_unshift($languages, 'Choose a language');
$builder->add('code', 'choice', array('choices' => $languages))->add('author', 'text')->add('comment', 'text')->add('messagesValues', 'collection', array('type' => 'text'));
}
作者:rouff
项目:symfon
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilder $builder, array $options)
{
// Overwrite required option for child fields
$options['first_options']['required'] = $options['required'];
$options['second_options']['required'] = $options['required'];
$builder->appendClientTransformer(new ValueToDuplicatesTransformer(array($options['first_name'], $options['second_name'])))->add($options['first_name'], $options['type'], array_merge($options['options'], $options['first_options']))->add($options['second_name'], $options['type'], array_merge($options['options'], $options['second_options']));
}