내 프로젝트에 이벤트, OrganizerProfile 및 User라는 세 개의 문서가 있습니다.Symfony3 : 중첩 된 (선택 사항) 양식 유효성 확인
사용자는 여러 OrganizerProfile (Facebook의 '페이지'와 같음) 및 이벤트를 가질 수 있습니다.
사용자가 만들고 이벤트를하면 "OrganizerProfile"을 이벤트에 할당 할 수 있습니다 (사용자 Alberto가 "이벤트 X"라는 "회사 A"에 대한 이벤트를 만듭니다).
OrganizerProfileType.php
class OrganizerProfileType extends AbstractType{
public function buildForm(FormBuilderInterface $builder, array $options){
$builder
->add('email', EmailType::class)
->add('name', TextType::class)
->add('description', TextType::class, ['required' => false])
...
EventType.php 분야 "profile_list"사용자에
class EventType extends AbstractType {
public function buildForm(FormBuilderInterface $builder, array $options)
{
$profileChoices = ... //List of existing profiles
$builder
->add('profile_list', ChoiceType::class, [
'choices' => $profileChoices,
'required' => false,
'mapped' => false,
])
->add('profile', OrganizerProfileType::class, [
'required' => true,
])
->add('title', TextType::class, ['required' => false])
->add('description', TextType::class, ['required' => false])
...
:
이를 달성하려면,이 형태를 만들었습니다 기존 OrganizerProfiles를 찾을 수 있습니다. 사용자는 그 중 하나를 선택하여 이벤트에 할당 할 수 있지만 사용자가 기존 프로파일을 선택하지 않으면 "프로파일"양식에 정보를 삽입해야합니다.
"선택 사항"을 프로필 양식으로 만들고 사용자가 기존 프로필을 선택하지 않은 경우에만 필요합니다.
어떻게하면됩니까? 감사합니다
[제출 된 데이터를 기반으로 검증 그룹을 선택하십시오.] (http://symfony.com/doc/current/form/data_based_validation.html) – Matteo