Optimized forms for user source

This commit is contained in:
Kevin Frantz 2018-09-14 15:08:51 +02:00
parent 1d7aaeb1dd
commit 04c0f5e9e7
3 changed files with 36 additions and 8 deletions

View File

@ -24,6 +24,8 @@ class UserSource extends AbstractSource implements UserSourceInterface
protected $user;
/**
* @Assert\Type(type="App\Entity\NameSource")
* @Assert\Valid()
* @ORM\OneToOne(targetEntity="NameSource",cascade={"persist", "remove"})
* @ORM\JoinColumn(name="name_id", referencedColumnName="id")
*

View File

@ -2,9 +2,23 @@
namespace App\Form;
/**
* @author kevinfrantz
*/
class NameSourceType
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\TextType;
class NameSourceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('name', TextType::class);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}

View File

@ -1,12 +1,24 @@
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
/**
* @author kevinfrantz
*/
class UserSourceType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('namesource', NameSourceType::class);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class
]);
}
}