symfony, cant pass validation on a embedded form + file - forms

Trying to embed a collection or just a simple type containing a file field, but both result in the same problem. On post the UploadedFile is present, but validation fails. "This value is not valid."
Bashing my head in all day, anyone?
Company form:
Simple embed with a file:
$builder->add('logo', new FileType(), [
'label' => 'Logo',
'required' => false,
'attr' => [
'accept' => 'image/*',
]
]);
Collection with files:
$builder->add('images', 'collection', array(
'type' => new FileType(),
'data' => [
new File(),
new File(),
new File(),
],
));
FileType:
class FileType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$data = $builder->getData();
$builder->add('file', 'file', [
'label' => 'Bestand',
]);
$builder->add('submit', 'submit', [
'label' => 'Save',
]);
}
public function getName()
{
return 'file';
}
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
'data_class' => 'Acme\DemoBundle\Entity\File',
));
}
}
The entity has a functioniong one-to-many from Company to File.
Everything works, but when the form is submitted. Both fields have a "This value is not valid." error.
Here is a dump of the clientData preSubmit:
'logo' =>
object(Symfony\Component\HttpFoundation\File\UploadedFile)[13]
private 'test' => boolean false
private 'originalName' => string 'etc.jpg' (length=13)
private 'mimeType' => string 'image/jpeg' (length=10)
private 'size' => int 103843
private 'error' => int 0
'images' =>
array (size=3)
0 =>
object(Symfony\Component\HttpFoundation\File\UploadedFile)[14]
private 'test' => boolean false
private 'originalName' => string 'Screen Shot 2014-07-24 at 17.15.30.png' (length=38)
private 'mimeType' => string 'image/png' (length=9)
private 'size' => int 84102
private 'error' => int 0
1 => null
2 => null
Seems perfectly fine to me!

Related

Symfony TypeTestCase How to populate collection of embedded form using mock?

For a simple blog manager where I want to associate some tags to some Post I have create a repository able to create a new entity when it's name can't be found in database:
public function requireByName(string $name): PostTag
{
$result = $this->findOneBy(['name' => [$name]]);
if (!$result instanceof PostTag) {
$result = $this->create($name);
$this->getEntityManager()->flush();
}
return $result;
}
I have managed to create a form TagType populating PostTag entity with the results of the PostTagRepository::requireByName method:
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder->add('name', TextType::class, [
'setter' => function (PostTag &$tag, string $name) {
$tag = $this->tagRepository->requireByName($name);
},
]);
}
All of this is tested with the instruction provided in Symfony documentation How to unit test your form
public function testItSetsRepositoryResultToInboundModel(): void
{
$formTagName = 'my new tag';
$formData = ['name' => $formTagName];
$createdPostTag = new PostTag($formTagName);
$this->tagRepository->method('requireByName')
->with($formTagName)
->willReturn($createdPostTag);
$this->testedForm->submit($formData);
self::assertTrue($this->testedForm->isSynchronized());
$formEntity = $this->testedForm->getData();
self::assertInstanceOf(PostTag::class, $formEntity);
self::assertSame($createdPostTag, $formEntity);
}
public function testItMapsTagsWithItsNameInFormField(): void
{
$tagName = 'my new tag';
$formData = new PostTag($tagName);
$form = $this->factory->create(TagType::class, $formData);
self::assertTrue($form->has('name'));
self::assertEquals($tagName, $form->get('name')->getData());
}
My next step is to create a TypeTestCase for my PostType form where I can assume that results from PostTagRepository are populated in my Post entity once I submit an array of tag names. Here is the code I produced so far (I load some extensions - Validator, CKEditor - required from the legacy behavior) :
class PostTypeTest extends TypeTestCase
{
use ValidatorExtensionTrait;
private PostTagRepository&MockObject $tagRepository;
protected function setUp(): void
{
$this->tagRepository = $this->createMock(PostTagRepository::class);
parent::setUp(); // TODO: Change the autogenerated stub
}
/** #return FormExtensionInterface[]
*
* #throws Exception
*/
protected function getExtensions(): array
{
$tagType = new TagType($this->tagRepository);
return [
$this->getValidatorExtension(),
$this->getCKEditorExtension(),
new PreloadedExtension([$tagType], []),
];
}
private function getCKEditorExtension(): PreloadedExtension
{
$CKEditorType = new CKEditorType($this->createMock(CKEditorConfigurationInterface::class));
return new PreloadedExtension([$CKEditorType], []);
}
public function testItMapsRepositoryResultToTagCollection(): void
{
$model = new Post();
$form = $this->factory->create(PostType::class, $model);
$requiredTag = new PostTag('poo');
$this->tagRepository->method('requireByName')
->with('poo')
->willReturn($requiredTag);
$form->submit([
'title' => 'a title',
'content' => 'some content',
'isPublic' => true,
'tags' => [
['name' => 'poo'],
],
]);
self::assertTrue($form->isSynchronized());
self::assertNotEmpty($model->getTags());
}
}
And here is the PostType code :
class PostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options): void
{
$builder
->add('title', TextType::class, [
'label' => 'Titre',
'required' => true,
'constraints' => [new Assert\NotBlank(), new Assert\Length(['min' => 5, 'max' => 255])],
]
)
->add(
'content',
CKEditorType::class,
[
'required' => true,
'label' => 'Contenu',
'config' => [
'filebrowserBrowseRoute' => 'elfinder',
'filebrowserBrowseRouteParameters' => [
'instance' => 'default',
'homeFolder' => '',
],
],
]
)
->add('isPublic', CheckboxType::class, [
'label' => 'Le Post est public',
'required' => false,
])
->add('tags', CollectionType::class, [
'entry_type' => TagType::class,
'entry_options' => ['label' => false],
])
->add('submit', SubmitType::class, [
'label' => 'app.actions.validate',
]);
}
public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults(
[
'data_class' => Post::class,
]
);
}
}
All properties are populated with submitted values but the $model->getTags() Collection remains empty.
Help would be really appreciated if someone could tell me what I am doing wrong ?

symfony validation error on nested form for dynamically modified field

I have an embedded forms with a entity field Activity in a sub form dynamically populated with data from a field Module whose data are set via ajax request.
But when i submit the form i have a validation error ("this value is not valid") and the activity field is blank.
The principle :
the main form (Session) has an entity field module and contains a collection (Timeslot).
The Timeslot subform has a field activity whose content depends on the Module value.
My forms :
class SessionType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('module', EntityType::class, [
'label' => 'module.name',
'required' => true,
'class' => Module::class,
'placeholder' => 'choose',
])
->add('timeslots', CollectionType::class, [
'required' => true,
'constraints' => new Valid(),
'prototype_name' => '__timeslot_prot__',
'entry_type' => TimeslotType::class,
'entry_options' => ['module' => isset($module) ? $module->getId() : 0],
'by_reference' => false,
'allow_add' => true,
'allow_delete' => true,
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Session::class,
'module' => null,
]);
}
}
And the Timeslot
class TimeslotType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$module = $options['module'];
$builder
->add('activity', EntityType::class, [
'class' => Activity::class,
'multiple' => false,
'required' => true,
'constraints' => new NotBlank(),
'query_builder' => function (ActivityRepository $activity) use ($module) {
if (null !== $module) {
$qb = $activity->createQueryBuilder('a')
->join('a.activityGroups', 'ag')
->join('ag.module', 'm')
->where('m.id = :mid')
->setParameter('mid', $module)
->orderBy('a.name', 'ASC');
return $qb;
} else {
$qb = $activity->createQueryBuilder('a')
->where('a.id = 0');
return $qb;
}
},
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Timeslot::class,
'module' => null,
]);
}
}
I also have a javascript script which fills the Activity select options with a query through an ajax call.
I also tried to modify my TimeslotType following this symfony doc
but i stumble upon the problem that in my case, the Module field is not in the same formBuilder than Activity, so the POST_SUBMIT eventlistener can't be applied in my case.
class TimeslotType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$module = $options['module'];
$formModifier = function (FormInterface $form, Module $module = null) {
$activities = [];
if (null !== $module){
foreach($module->getActivityGroups() as $ag){
foreach($ag->getActivities() as $activity){
$activities[] = $activity;
}
}
}
$form->add('activity', EntityType::class, [
'label' => 'timeslot.activity',
'label_attr' => ['class' => 'mandatory', 'data-extrainfo' => 'panel_timeslot'],
'attr' => [
'class' => 'activitieslist',
],
'class' => Activity::class,
'multiple' => false,
'required' => true,
'constraints' => new NotBlank(),
'choices' => $activities,
'choices_as_values' => true,
]);
};
$builder->addEventListener(
FormEvents::PRE_SET_DATA,
function (FormEvent $event) use ($formModifier) {
// the entity : Timeslot
$data = $event->getData();
$formModifier($event->getForm(), $module);
}
);
//$builder->get('module') ... Makes no sense here since the module attribute is not a Timeslot, but belongs to Session
/*
$builder->get('module')->addEventListener(FormEvents::PRE_SUBMIT,
function (FormEvent $event) use ($formModifier) {
$module = $event->getForm()->getData();
$formModifier($event->getForm()->getParent(), $module);
}
);
*/
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => Timeslot::class,
'module' => null,
]);
}
}
How can i resolve my problem and validate my form ?
===
Edit
The ajax request is called when the module field is changed
function updateActivities(block) {
var module = $('#session_module').val();
if (module != ''){
$.ajax({
url: Routing.generate('project_module_activities_ajax', {}),
data: { 'module': module },
method: 'POST',
success: function (activities) {
var sel = '';
for (var i = 0; i < activities.length; i++) {
sel += '<option value="' + activities[i].id + '">' + activities[i].name + '</option>'
}
$('#litimeslot'+block).find('.activitieslist').each(function () {
$(this).html(sel);
})
}
});
}
}
And the route project_module_activities_ajax simply returns an array of activities for the module from a query
something like :
[
['id' : 1, 'name' : 'activity 1'],
['id' : 2, 'name' : 'activity 2'],
}
Edit 2
if i add this eventlistener in the TimeslotType :
$builder->addEventListener(FormEvents::PRE_SUBMIT,
function (FormEvent $event) use ($moduleId) {
$form = $event->getForm();
$data = $event->getData();
echo '<pre>form AFTER=';var_dump($form->getData());echo '</pre>';
echo '<pre>data AFTER=';var_dump($data);echo '</pre>';
echo '<pre>module AFTER';var_dump($moduleId);echo '</pre>';
}
);
I have
form AFTER= NULL
data AFTER= array(
["activity"]=>
string(3) "573" <= which is the value i selected
...
)
module AFTER int(0)

Zend - Dynamic form dropdown

I start with zend framework and I'm having trouble implementing a dynamic drop-down list.
I need to create a simple dropdown list of events select from the database.
This is my Module class :
public function getFormElementConfig()
{
return array(
"factories" => [
'participant_form' => function (ServiceManager $serviceManager) {
/** #var EntityManager $entityManager */
$entityManager = $serviceManager->get("doctrine.entitymanager.orm_default");
$events = $entityManager->getRepository('Application\Entity\Event')->findAll();
$eventForSelect = array();
foreach ($events as $event) {
$eventForSelect[$event->getId()] = $event->getName();
}
/** #var \Zend\Form\Form $form */
$form = new ParticipantForm();
$form->setHydrator(new DoctrineHydrator($entityManager));
$form->setObject(new Participant());
$form->setOption('event_for_select', $eventForSelect);
return $form;
},
]
);
}
but I do not know how to get the option 'event_for_select' in my form :
class ParticipantForm extends Form
{
public function __construct($name = null)
{
parent::__construct('user');
$this->setAttribute('class', 'form-horizontal');
$this->add([
'name' => 'id',
'type' => 'Hidden',
]);
$this->add([
'name' => 'firstname',
'type' => 'Text',
'options' => [
'label' => 'Prénom',
],
]);
$this->add([
'name' => 'event',
'type' => 'Select',
'options' => [
'label' => 'Event',
'value_options' => // ?? $event_for_select
],
]);
Thanks for your help !
Add field in your form class:
class ParticipantForm extends Form
{
protected $eventForSelect;
public function setEventForSelect($eventForSelect)
{
$this->eventForSelect = $eventForSelect;
// update field value options
$this->get('event')
->setValueOptions($this->eventForSelect);
return $this;
}
// rest of form class code
}
Then use setEventForSelect() method in your factory:
/** #var \Zend\Form\Form $form */
$form = new ParticipantForm();
$form->setHydrator(new DoctrineHydrator($entityManager));
$form->setObject(new Participant());
$form->setEventForSelect($eventForSelect);
return $form;
And then in form:
$this->add([
'name' => 'event',
'type' => 'Select',
'options' => [
'label' => 'Event',
'value_options' => $this->eventForSelect,
],
]);

Symfony 3.3 Form - EntityType field does not select option

For some unknown reason, the EntityType form field will not display the selected option on submit, even though the name of the column matches and data passes.
I've created a form that I'm using to select some values that will filter a list of products.
<?php namespace AppBundle\Filter;
use AppBundle\Entity\ProductCategory;
use AppBundle\Repository\ProductCategoryRepository;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
class ProductFilterType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('id', null, [
'required' => false,
'label' => 'SKU'
])
->add('productCategory', EntityType::class,
array(
'class' => ProductCategory::class,
'choice_label' => 'name',
'choice_value' => 'id',
'placeholder' => '',
'label_attr' => array('title' => 'Category for this product'),
'query_builder' => function (ProductCategoryRepository $v) {
return $v->createQueryBuilder('v')
->orderBy('v.name',' ASC');
}
))
->add('name', null, [
'required' => false,
])
->add('description', null, [
'required' => false,
])
;
}
/**
* {#inheritdoc}
*/
public function getBlockPrefix()
{
return 'app_bundle_product_filter_type';
} }
The form renders as expected, and it submits a post to the same URL, which filters based on the value received from the request.
That works ok.
However, when the form is re-rendered, the option that was selected before the form filter submission is no longer selected. All other inputs are repopulating.
I did notice that when I'm working with a form that is bound to an Entity (ie: Editting and saving the entity) and using the ConfigureOptions method to set the data class, that the EntityType form field works as expected. However, I need it to work in this case where the overall form is not bound to an Entity.
EDIT:
Doing these steps worked for me...but it seems a bit odd.
Injected entity manager into the form constructor:
public $em;
public function __construct(EntityManager $em) {
$this->em = $em;
}
Then updated the EntityType form field to get the object based on the array value:
->add('productCategory', EntityType::class,
array(
'class' => ProductCategory::class,
'choice_label' => 'name',
'choice_value' => 'id',
'placeholder' => '',
'label_attr' => array('title' => 'Category for this product'),
'data' => $this->em->getReference("AppBundle:ProductCategory",
isset($options['data']['productCategory']) ? $options['data']['productCategory'] : 0),
'query_builder' => function (ProductCategoryRepository $v) {
return $v->createQueryBuilder('v')
->orderBy('v.name',' ASC');
}
))
...
Another solution is using a Data Transformer.
Remove the data attribute from the productCategory type, and add a data transformer to the end of the build method:
$builder->get('productCategory')
->addModelTransformer(new CallbackTransformer(
function ($id) {
if (!$id) {
return;
}
return $this->em->getRepository('AppBundle:ProductCategory')->find($id);
},
function($category) {
return $category->getId();
}
));
If you use the same transformer in multiple places, you can extract it into its own class.
My workaround was like this ...
pass data and entity manager to formType.
$form = $this->createForm(new xxxType($this->get('doctrine.orm.entity_manager')), xxxEntity, array(
'method' => 'POST',
'action' => $this->generateUrl('xxxurl', array('id' => $id)),
'selectedId' => xxxId,
));
setDefaultOptions in form Type initialize as an empty array for selectedId
$resolver->setDefaults(array(
'data_class' => 'xxx',
'selectedId' => array()
));
and in builder
->add('productCategory', EntityType::class,
array(
'class' => ProductCategory::class,
'choice_label' => 'name',
'choice_value' => 'id',
'placeholder' => '',
'label_attr' => array('title' => 'Category for this product'),
'query_builder' => function (ProductCategoryRepository $v) {
return $v->createQueryBuilder('v')
->orderBy('v.name',' ASC');
},
'data'=>$this->em->getReference("xxx",$options['selectedId'])
))
for more details, you can see this answer Symfony2 Setting a default choice field selection

Symfony3.3 form name not in Request

Heads up - I've already been here. Strange issue with Symfony3 forms. So I've created FormType class:
class GetPostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->setMethod("POST")
->add('phrase', Type\TextType::class);
}
}
As you can see form is not bound to any entity or other object(this shouldn't matter though). Now when I try to handle incoming request with that form:
$postForm = $this->createForm(GetPostType::class);
$postForm->handleRequest($this->request);
... normally handleRequest should submit my form. However:
$postForm->isSubmitted();
is false.
I've tracked down source of issue to HttpFoundationRequestHandler.
} elseif ($request->request->has($name) || $request->files->has($name)) {
According to this my form name is not present in request. That's what I don't get. I'm using Symfony forms at work and there's no problem. I used them in different projects and it was ok. Now for some reason I can't get them to work. It is probably something obvious but I guess I need another pair of eyes to see it.
As you can see I did try to set form method manually(it should be POST by default) but it didn't work. I did clear the cache and stuff. I did try different things I found on the internet but no luck.
I can't find anything that might be the reason. Any ideas what it might be?
UPDATE:
As requested in comments section I provide dump of my request object.
So how do I know it is the right thing? It is accepted by handleRequest method witch expects request type and it contains correct data.
/var/www/story/src/CodeCraft/BlogBundle/Controller/Api/PostController.php:73:
object(Symfony\Component\HttpFoundation\Request)[49]
public 'attributes' =>
object(Symfony\Component\HttpFoundation\ParameterBag)[12]
protected 'parameters' =>
array (size=4)
'_controller' => string 'CodeCraft\BlogBundle\Controller\Api\PostController::getPostsAction' (length=66)
'_route' => string 'blog.api.posts.get' (length=18)
'_route_params' =>
array (size=0)
...
'_firewall_context' => string 'security.firewall.map.context.main' (length=34)
public 'request' =>
object(Symfony\Component\HttpFoundation\ParameterBag)[10]
protected 'parameters' =>
array (size=1)
'phrase' => string 'xxx' (length=3)
public 'query' =>
object(Symfony\Component\HttpFoundation\ParameterBag)[11]
protected 'parameters' =>
array (size=0)
empty
public 'server' =>
object(Symfony\Component\HttpFoundation\ServerBag)[15]
protected 'parameters' =>
array (size=34)
'HTTP_CACHE_CONTROL' => string 'no-cache' (length=8)
'HTTP_POSTMAN_TOKEN' => string '2eea2285-a2f7-4ca5-a799-ea97758d7d20' (length=36)
'CONTENT_TYPE' => string 'application/x-www-form-urlencoded' (length=33)
'HTTP_USER_AGENT' => string 'PostmanRuntime/6.1.6' (length=20)
'HTTP_ACCEPT' => string '*/*' (length=3)
'HTTP_HOST' => string 'story.dev' (length=9)
'HTTP_ACCEPT_ENCODING' => string 'gzip, deflate' (length=13)
'CONTENT_LENGTH' => string '10' (length=2)
'HTTP_CONNECTION' => string 'keep-alive' (length=10)
'PATH' => string '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin' (length=60)
'SERVER_SIGNATURE' => string '<address>Apache/2.4.18 (Ubuntu) Server at story.dev Port 80</address>
' (length=70)
'SERVER_SOFTWARE' => string 'Apache/2.4.18 (Ubuntu)' (length=22)
'SERVER_NAME' => string 'story.dev' (length=9)
'SERVER_ADDR' => string '192.168.33.10' (length=13)
'SERVER_PORT' => string '80' (length=2)
'REMOTE_ADDR' => string '192.168.33.1' (length=12)
'DOCUMENT_ROOT' => string '/var/www/story/web' (length=18)
'REQUEST_SCHEME' => string 'http' (length=4)
'CONTEXT_PREFIX' => string '' (length=0)
'CONTEXT_DOCUMENT_ROOT' => string '/var/www/story/web' (length=18)
'SERVER_ADMIN' => string 'webmaster#localhost' (length=19)
'SCRIPT_FILENAME' => string '/var/www/story/web/app_dev.php' (length=30)
'REMOTE_PORT' => string '57039' (length=5)
'GATEWAY_INTERFACE' => string 'CGI/1.1' (length=7)
'SERVER_PROTOCOL' => string 'HTTP/1.1' (length=8)
'REQUEST_METHOD' => string 'POST' (length=4)
'QUERY_STRING' => string '' (length=0)
'REQUEST_URI' => string '/app_dev.php/posts' (length=18)
'SCRIPT_NAME' => string '/app_dev.php' (length=12)
'PATH_INFO' => string '/posts' (length=6)
'PATH_TRANSLATED' => string '/var/www/story/web/posts' (length=24)
'PHP_SELF' => string '/app_dev.php/posts' (length=18)
'REQUEST_TIME_FLOAT' => float 1509896560.734
'REQUEST_TIME' => int 1509896560
public 'files' =>
object(Symfony\Component\HttpFoundation\FileBag)[14]
protected 'parameters' =>
array (size=0)
empty
public 'cookies' =>
object(Symfony\Component\HttpFoundation\ParameterBag)[13]
protected 'parameters' =>
array (size=0)
empty
public 'headers' =>
object(Symfony\Component\HttpFoundation\HeaderBag)[16]
protected 'headers' =>
array (size=10)
'cache-control' =>
array (size=1)
...
'postman-token' =>
array (size=1)
...
'content-type' =>
array (size=1)
...
'user-agent' =>
array (size=1)
...
'accept' =>
array (size=1)
...
'host' =>
array (size=1)
...
'accept-encoding' =>
array (size=1)
...
'content-length' =>
array (size=1)
...
'connection' =>
array (size=1)
...
'x-php-ob-level' =>
array (size=1)
...
protected 'cacheControl' =>
array (size=1)
'no-cache' => boolean true
protected 'content' => null
protected 'languages' => null
protected 'charsets' => null
protected 'encodings' => null
protected 'acceptableContentTypes' => null
protected 'pathInfo' => string '/posts' (length=6)
protected 'requestUri' => string '/app_dev.php/posts' (length=18)
protected 'baseUrl' => string '/app_dev.php' (length=12)
protected 'basePath' => null
protected 'method' => string 'POST' (length=4)
protected 'format' => null
protected 'session' =>
object(Symfony\Component\HttpFoundation\Session\Session)[5070]
protected 'storage' =>
object(Symfony\Component\HttpFoundation\Session\Storage\NativeSessionStorage)[5071]
protected 'bags' =>
array (size=2)
...
protected 'started' => boolean false
protected 'closed' => boolean false
protected 'saveHandler' =>
object(Symfony\Component\HttpFoundation\Session\Storage\Proxy\SessionHandlerProxy)[5090]
...
protected 'metadataBag' =>
object(Symfony\Component\HttpFoundation\Session\Storage\MetadataBag)[5065]
...
private 'flashName' => string 'flashes' (length=7)
private 'attributeName' => string 'attributes' (length=10)
protected 'locale' => null
protected 'defaultLocale' => string 'en' (length=2)
private 'isHostValid' => boolean true
private 'isClientIpsValid' => boolean true
private 'isForwardedValid' => boolean true
The actual field that would be rendered by your form is named get_post[phrase], not just phrase. Submitting get_post[phrase] in postman will work.
If you don't want that naming scheme you can override the getBlockPrefix method in your Form, eg:
<?php
namespace AppBundle\Form;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class GetPostType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('phrase', TextType::class);
}
public function getBlockPrefix()
{
return null;
}
}