diff --git a/application/src/Entity/UserSource.php b/application/src/Entity/UserSource.php index ff14834..5f4807d 100644 --- a/application/src/Entity/UserSource.php +++ b/application/src/Entity/UserSource.php @@ -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") * diff --git a/application/src/Form/NameSourceType.php b/application/src/Form/NameSourceType.php index 63020a7..58576c9 100644 --- a/application/src/Form/NameSourceType.php +++ b/application/src/Form/NameSourceType.php @@ -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, + ]); + } } diff --git a/application/src/Form/UserSourceType.php b/application/src/Form/UserSourceType.php index 9fcd410..21f0127 100644 --- a/application/src/Form/UserSourceType.php +++ b/application/src/Form/UserSourceType.php @@ -1,12 +1,24 @@ add('namesource', NameSourceType::class); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver->setDefaults([ + 'data_class' => User::class + ]); + } } +