Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/src/Apikey/ApikeyController.php
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public function deleteApiKey($username, $apikey)
$data['apikey_id'] = $apikey->getId();

$factory = $this->application->formFactory;
$form = $factory->create(new ApikeyDeleteFormType(), $data);
$form = $factory->create(ApikeyDeleteFormType::class, $data);

$request = $this->application->request();

Expand Down
3 changes: 2 additions & 1 deletion app/src/Apikey/ApikeyDeleteFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Apikey;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Event\EventEntity;
Expand Down Expand Up @@ -36,7 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add(
'apikey_id',
'hidden',
HiddenType::class,
[]
)
;
Expand Down
2 changes: 1 addition & 1 deletion app/src/Application/ApplicationController.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function contact()

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new ContactFormType());
$form = $factory->create(ContactFormType::class);

if ($request->isPost()) {
$form->submit($request->post($form->getName()));
Expand Down
23 changes: 14 additions & 9 deletions app/src/Application/ContactFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
namespace Application;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Form\DataTransformer\DateTransformer;
Expand All @@ -14,9 +16,8 @@
* Usage (extraneous use of variables is made to illustrate which parts are used):
*
* ```
* $formType = new EventFormType();
* $factory = $this->application->formFactory;
* $form = $factory->create($formType);
* $form = $factory->create(EventFormType::class);
* $formName = $form->getName();
*
* if ($this->application->request()->isPost()) {
Expand Down Expand Up @@ -58,39 +59,43 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add(
'name',
'text',
TextType::class,
[
'constraints' => [new Assert\NotBlank(), new Assert\Length(['max' => 100])],
'max_length' => '100',
'attr' => [
'maxlength' => '100',
]
]
)
->add(
'email',
'text',
TextType::class,
[
'required' => true,
'constraints' => [new Assert\NotBlank(), new Assert\Email()],
]
)
->add(
'subject',
'text',
TextType::class,
[
'constraints' => [new Assert\NotBlank(), new Assert\Length(['max' => 100])],
'max_length' => '100',
'attr' => [
'maxlength' => '100',
]
]
)
->add(
'comment',
'textarea',
TextareaType::class,
[
'required' => true,
'constraints' => [new Assert\NotBlank()],
]
)
->add(
'phone',
'text',
TextType::class,
[
'constraints' => [new Assert\Blank()],
]
Expand Down
6 changes: 3 additions & 3 deletions app/src/Client/ClientController.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ public function createClient($username)

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new ClientFormType());
$form = $factory->create(ClientFormType::class);

if ($request->isPost()) {
$form->submit($request->post($form->getName()));
Expand Down Expand Up @@ -163,7 +163,7 @@ public function editClient($username, $clientName)

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new ClientFormType(), $data);
$form = $factory->create(ClientFormType::class, $data);

$request = $this->application->request();
if ($request->isPost()) {
Expand Down Expand Up @@ -266,7 +266,7 @@ public function deleteClient($username, $clientName)
$data['client_id'] = $client->getId();

$factory = $this->application->formFactory;
$form = $factory->create(new ClientDeleteFormType(), $data);
$form = $factory->create(ClientDeleteFormType::class, $data);

$request = $this->application->request();

Expand Down
3 changes: 2 additions & 1 deletion app/src/Client/ClientDeleteFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Client;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Event\EventEntity;
Expand Down Expand Up @@ -36,7 +37,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add(
'client_id',
'hidden',
HiddenType::class,
[]
)
;
Expand Down
9 changes: 6 additions & 3 deletions app/src/Client/ClientFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
namespace Client;

use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;
use Event\EventEntity;
Expand Down Expand Up @@ -36,22 +39,22 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$builder
->add(
'application',
'text',
TextType::class,
[
'constraints' => [new Assert\NotBlank()],
]
)
->add(
'description',
'textarea',
TextareaType::class,
[
'constraints' => [new Assert\NotBlank()],
'attr' => ['rows' => '10']
]
)
->add(
'callback_url',
'url',
UrlType::class,
[
'constraints' => [
new Assert\Url(),
Expand Down
15 changes: 10 additions & 5 deletions app/src/Event/EventController.php
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ public function submit()

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new EventFormType());
$form = $factory->create(EventFormType::class);

if ($request->isPost()) {
$form->submit($request->post($form->getName()));
Expand Down Expand Up @@ -585,7 +585,7 @@ public function edit($friendly_name)

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new EventFormType(), $event);
$form = $factory->create(EventFormType::class, $event);
if ($request->isPost()) {
$form->submit($request->post($form->getName()));

Expand Down Expand Up @@ -1034,7 +1034,12 @@ public function addTalk($friendly_name)

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new TalkFormType($event, $languages, $talkTypes, $tracks), $data);
$form = $factory->create(TalkFormType::class, $data, [
'event' => $event,
'languages' => $languages,
'talkTypes' => $talkTypes,
'tracks' => $tracks,
]);

$request = $this->application->request();
if ($request->isPost()) {
Expand Down Expand Up @@ -1105,7 +1110,7 @@ public function editTracks($friendly_name)
}

$factory = $this->application->formFactory;
$form = $factory->create(new TrackCollectionFormType(), $data);
$form = $factory->create(TrackCollectionFormType::class, $data);

$request = $this->application->request();
if ($request->isPost()) {
Expand Down Expand Up @@ -1171,7 +1176,7 @@ public function eventImportCsv($eventSlug)

/** @var FormFactoryInterface $factory */
$factory = $this->application->formFactory;
$form = $factory->create(new EventImportFormType());
$form = $factory->create(EventImportFormType::class);

//use EventFormImportType to validate the CSV is valid
//We possibly want to do some extensive data checking
Expand Down
44 changes: 26 additions & 18 deletions app/src/Event/EventFormType.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
use Form\DataTransformer\EventTagsTransformer;
use Form\Listener\GetResolvedUrlListener;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\FileType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\UrlType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -66,17 +72,17 @@ public function buildForm(FormBuilderInterface $builder, array $options)

$dateTransformer = new DateTransformer($timezone);
$builder
->add('addr', 'hidden', ['mapped' => false])
->add('addr', HiddenType::class, ['mapped' => false])
->add(
'name',
'text',
TextType::class,
[
'constraints' => [new Assert\NotBlank(), new Assert\Length(['min' => 5])],
]
)
->add(
'description',
'textarea',
TextareaType::class,
[
'constraints' => [new Assert\NotBlank(), new Assert\Length(['min' => 5])],
'attr' => [
Expand All @@ -87,7 +93,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
->add(
$builder->create(
'tags',
'text',
TextType::class,
[
'required' => false,
'attr' => ['placeholder' => 'comma separated, tag, list']
Expand All @@ -96,91 +102,93 @@ public function buildForm(FormBuilderInterface $builder, array $options)
)
->add(
'tz_continent',
'choice',
ChoiceType::class,
[
'label' => 'Timezone',
'choices' => ["Select a continent"] + $continents,
'placeholder' => 'Select a continent',
'choices' => $continents,
'constraints' => [new Assert\NotBlank()],
]
)
->add(
'tz_place',
'choice',
ChoiceType::class,
[
'label' => 'Timezone city',
'choices' => ['Select a city'] + $cities,
'placeholder' => 'Select a city',
'choices' => $cities,
'constraints' => [new Assert\NotBlank()],
]
)
->add(
$builder->create(
'start_date',
'text',
TextType::class,
$this->getOptionsForDateWidget('Start date')
)->addViewTransformer($dateTransformer)
)
->add(
$builder->create(
'end_date',
'text',
TextType::class,
$this->getOptionsForDateWidget('End date')
)->addViewTransformer($dateTransformer)
)
->add(
$builder->create(
'href',
'url',
UrlType::class,
$this->getOptionsForUrlWidget('Website URL', true)
)->addEventSubscriber(new GetResolvedUrlListener())
)
->add(
$builder->create(
'cfp_start_date',
'text',
TextType::class,
$this->getOptionsForDateWidget('Opening date', false)
)->addViewTransformer($dateTransformer)
)
->add(
$builder->create(
'cfp_end_date',
'text',
TextType::class,
$this->getOptionsForDateWidget('Closing date', false)
)->addViewTransformer($dateTransformer)
)
->add(
$builder->create(
'cfp_url',
'url',
UrlType::class,
$this->getOptionsForUrlWidget('Call for papers URL', false)
)->addEventSubscriber(new GetResolvedUrlListener())
)
->add(
'location',
'text',
TextType::class,
[
'label' => 'Venue name',
'constraints' => [new Assert\NotBlank()],
]
)
->add(
'latitude',
'text',
TextType::class,
[
'label' => 'Latitude',
'attr' => ['readonly' => 'readonly'],
]
)
->add(
'longitude',
'text',
TextType::class,
[
'label' => 'Longitude',
'attr' => ['readonly' => 'readonly'],
]
)
->add(
'new_icon',
'file',
FileType::class,
[
'data_class' => null,
'label' => 'Upload new icon',
Expand Down
Loading