Form option required AND not required
I have a big problem and after hours of research I haven't find any answer...
I have 2 forms, and i'm calling one in the other.
When i give to my form the "entity_manager" option I have this error message :
The option "entity_manager" does not exist.
BUT, when i delete this option I have the following :
The required option "entity_manager" is missing.
There is my code :
CandidatureController.php
$candidature = new Candidature();
$formCandidature = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'candidature'));
$formCandidature->handleRequest($request);
$formOrientation = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'orientation'));
CandidatureType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$this->em = $options['entity_manager'];
$form = $options['form'];
if ($form == 'candidature') {
$builder->add('caCommentairesituation', TextareaType::class)
->add('caCommentaire', TextareaType::class)
->add('profils', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => ProfilType::class,'allow_add' => true, 'allow_delete' => true,'prototype' => true))
->add('fkMobilitegeographique', EntityType::class, array('class'=>'PDFRecrutementBundleEntityMobilitegeographique', 'choice_label'=>'mgLibelle'))
->add('fkSituationprofessionnelle',EntityType::class, array('class'=>'PDFRecrutementBundleEntitySituationprofessionnelle', 'choice_label'=>'spLibelle'))
->add('fkTypecandidature', EntityType::class, array('class'=>'PDFRecrutementBundleEntityTypecandidature', 'choice_label'=>'tcLibelle'))
->add('fkProvenance', EntityType::class, array('class'=>'PDFRecrutementBundleEntityProvenance', 'choice_label'=>'prLibelle'));
} else {
$builder->add('orientations', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => OrientationType::class, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true));
}
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityCandidature',
'form' => false
));
$resolver->setRequired('entity_manager');
}
OrientationType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('orLibelle', TextType::class)
->add('orDescription', TextType::class)
->add('orArchive')
->add('orDiffusion')
->add('fkCategorieorientation', EntityType::class, array('class'=>'PDFRecrutementBundleEntityCategorieOrientation', 'choice_label'=>'coLibelle'))
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true));
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityOrientation'
));
}
So how can I resolve this ?
PS : Sorry for my bad english.
php forms symfony
add a comment |
I have a big problem and after hours of research I haven't find any answer...
I have 2 forms, and i'm calling one in the other.
When i give to my form the "entity_manager" option I have this error message :
The option "entity_manager" does not exist.
BUT, when i delete this option I have the following :
The required option "entity_manager" is missing.
There is my code :
CandidatureController.php
$candidature = new Candidature();
$formCandidature = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'candidature'));
$formCandidature->handleRequest($request);
$formOrientation = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'orientation'));
CandidatureType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$this->em = $options['entity_manager'];
$form = $options['form'];
if ($form == 'candidature') {
$builder->add('caCommentairesituation', TextareaType::class)
->add('caCommentaire', TextareaType::class)
->add('profils', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => ProfilType::class,'allow_add' => true, 'allow_delete' => true,'prototype' => true))
->add('fkMobilitegeographique', EntityType::class, array('class'=>'PDFRecrutementBundleEntityMobilitegeographique', 'choice_label'=>'mgLibelle'))
->add('fkSituationprofessionnelle',EntityType::class, array('class'=>'PDFRecrutementBundleEntitySituationprofessionnelle', 'choice_label'=>'spLibelle'))
->add('fkTypecandidature', EntityType::class, array('class'=>'PDFRecrutementBundleEntityTypecandidature', 'choice_label'=>'tcLibelle'))
->add('fkProvenance', EntityType::class, array('class'=>'PDFRecrutementBundleEntityProvenance', 'choice_label'=>'prLibelle'));
} else {
$builder->add('orientations', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => OrientationType::class, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true));
}
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityCandidature',
'form' => false
));
$resolver->setRequired('entity_manager');
}
OrientationType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('orLibelle', TextType::class)
->add('orDescription', TextType::class)
->add('orArchive')
->add('orDiffusion')
->add('fkCategorieorientation', EntityType::class, array('class'=>'PDFRecrutementBundleEntityCategorieOrientation', 'choice_label'=>'coLibelle'))
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true));
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityOrientation'
));
}
So how can I resolve this ?
PS : Sorry for my bad english.
php forms symfony
add a comment |
I have a big problem and after hours of research I haven't find any answer...
I have 2 forms, and i'm calling one in the other.
When i give to my form the "entity_manager" option I have this error message :
The option "entity_manager" does not exist.
BUT, when i delete this option I have the following :
The required option "entity_manager" is missing.
There is my code :
CandidatureController.php
$candidature = new Candidature();
$formCandidature = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'candidature'));
$formCandidature->handleRequest($request);
$formOrientation = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'orientation'));
CandidatureType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$this->em = $options['entity_manager'];
$form = $options['form'];
if ($form == 'candidature') {
$builder->add('caCommentairesituation', TextareaType::class)
->add('caCommentaire', TextareaType::class)
->add('profils', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => ProfilType::class,'allow_add' => true, 'allow_delete' => true,'prototype' => true))
->add('fkMobilitegeographique', EntityType::class, array('class'=>'PDFRecrutementBundleEntityMobilitegeographique', 'choice_label'=>'mgLibelle'))
->add('fkSituationprofessionnelle',EntityType::class, array('class'=>'PDFRecrutementBundleEntitySituationprofessionnelle', 'choice_label'=>'spLibelle'))
->add('fkTypecandidature', EntityType::class, array('class'=>'PDFRecrutementBundleEntityTypecandidature', 'choice_label'=>'tcLibelle'))
->add('fkProvenance', EntityType::class, array('class'=>'PDFRecrutementBundleEntityProvenance', 'choice_label'=>'prLibelle'));
} else {
$builder->add('orientations', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => OrientationType::class, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true));
}
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityCandidature',
'form' => false
));
$resolver->setRequired('entity_manager');
}
OrientationType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('orLibelle', TextType::class)
->add('orDescription', TextType::class)
->add('orArchive')
->add('orDiffusion')
->add('fkCategorieorientation', EntityType::class, array('class'=>'PDFRecrutementBundleEntityCategorieOrientation', 'choice_label'=>'coLibelle'))
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true));
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityOrientation'
));
}
So how can I resolve this ?
PS : Sorry for my bad english.
php forms symfony
I have a big problem and after hours of research I haven't find any answer...
I have 2 forms, and i'm calling one in the other.
When i give to my form the "entity_manager" option I have this error message :
The option "entity_manager" does not exist.
BUT, when i delete this option I have the following :
The required option "entity_manager" is missing.
There is my code :
CandidatureController.php
$candidature = new Candidature();
$formCandidature = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'candidature'));
$formCandidature->handleRequest($request);
$formOrientation = $this->createForm('PDFRecrutementBundleFormCandidatureType', $candidature, array('entity_manager' => $entityManager, 'form' => 'orientation'));
CandidatureType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$this->em = $options['entity_manager'];
$form = $options['form'];
if ($form == 'candidature') {
$builder->add('caCommentairesituation', TextareaType::class)
->add('caCommentaire', TextareaType::class)
->add('profils', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => ProfilType::class,'allow_add' => true, 'allow_delete' => true,'prototype' => true))
->add('fkMobilitegeographique', EntityType::class, array('class'=>'PDFRecrutementBundleEntityMobilitegeographique', 'choice_label'=>'mgLibelle'))
->add('fkSituationprofessionnelle',EntityType::class, array('class'=>'PDFRecrutementBundleEntitySituationprofessionnelle', 'choice_label'=>'spLibelle'))
->add('fkTypecandidature', EntityType::class, array('class'=>'PDFRecrutementBundleEntityTypecandidature', 'choice_label'=>'tcLibelle'))
->add('fkProvenance', EntityType::class, array('class'=>'PDFRecrutementBundleEntityProvenance', 'choice_label'=>'prLibelle'));
} else {
$builder->add('orientations', CollectionType::class, array('entry_options' => ['entity_manager' => $this->em], 'entry_type' => OrientationType::class, 'allow_add' => true, 'allow_delete' => true, 'prototype' => true));
}
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityCandidature',
'form' => false
));
$resolver->setRequired('entity_manager');
}
OrientationType.php
public function buildForm(FormBuilderInterface $builder, array $options) {
$builder->add('orLibelle', TextType::class)
->add('orDescription', TextType::class)
->add('orArchive')
->add('orDiffusion')
->add('fkCategorieorientation', EntityType::class, array('class'=>'PDFRecrutementBundleEntityCategorieOrientation', 'choice_label'=>'coLibelle'))
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true));
}
public function configureOptions(OptionsResolver $resolver) {
$resolver->setDefaults(array(
'data_class' => 'PDFRecrutementBundleEntityOrientation'
));
}
So how can I resolve this ?
PS : Sorry for my bad english.
php forms symfony
php forms symfony
edited Nov 13 '18 at 13:42
Arthur MICHEL
asked Nov 12 '18 at 9:42
Arthur MICHELArthur MICHEL
105
105
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
In OrientationType.php, the entry type for your CollectionType "candidatures" is CandidatureType but you don't define 'entry_options' wich are options you pass to your entry type...
try to replace that
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true))
with that :
->add('candidatures', CollectionType::class, array(
'entry_type' => CandidatureType::class,
'entry_options' => [
'entity_manager' => $this->em
],
'allow_add' => true,
'allow_delete' => true)
);
Of course, you need to define $em as the entity_manager first in OrientationType, the same way you defined it in CandidatureType, with setRequired() should be just fine.
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259430%2fform-option-required-and-not-required%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
In OrientationType.php, the entry type for your CollectionType "candidatures" is CandidatureType but you don't define 'entry_options' wich are options you pass to your entry type...
try to replace that
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true))
with that :
->add('candidatures', CollectionType::class, array(
'entry_type' => CandidatureType::class,
'entry_options' => [
'entity_manager' => $this->em
],
'allow_add' => true,
'allow_delete' => true)
);
Of course, you need to define $em as the entity_manager first in OrientationType, the same way you defined it in CandidatureType, with setRequired() should be just fine.
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
add a comment |
In OrientationType.php, the entry type for your CollectionType "candidatures" is CandidatureType but you don't define 'entry_options' wich are options you pass to your entry type...
try to replace that
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true))
with that :
->add('candidatures', CollectionType::class, array(
'entry_type' => CandidatureType::class,
'entry_options' => [
'entity_manager' => $this->em
],
'allow_add' => true,
'allow_delete' => true)
);
Of course, you need to define $em as the entity_manager first in OrientationType, the same way you defined it in CandidatureType, with setRequired() should be just fine.
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
add a comment |
In OrientationType.php, the entry type for your CollectionType "candidatures" is CandidatureType but you don't define 'entry_options' wich are options you pass to your entry type...
try to replace that
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true))
with that :
->add('candidatures', CollectionType::class, array(
'entry_type' => CandidatureType::class,
'entry_options' => [
'entity_manager' => $this->em
],
'allow_add' => true,
'allow_delete' => true)
);
Of course, you need to define $em as the entity_manager first in OrientationType, the same way you defined it in CandidatureType, with setRequired() should be just fine.
In OrientationType.php, the entry type for your CollectionType "candidatures" is CandidatureType but you don't define 'entry_options' wich are options you pass to your entry type...
try to replace that
->add('candidatures', CollectionType::class, array('entry_type' => CandidatureType::class, 'allow_add' => true, 'allow_delete' => true))
with that :
->add('candidatures', CollectionType::class, array(
'entry_type' => CandidatureType::class,
'entry_options' => [
'entity_manager' => $this->em
],
'allow_add' => true,
'allow_delete' => true)
);
Of course, you need to define $em as the entity_manager first in OrientationType, the same way you defined it in CandidatureType, with setRequired() should be just fine.
edited Nov 12 '18 at 10:28
Arthur MICHEL
105
105
answered Nov 12 '18 at 10:00
Yoann MirYoann Mir
865
865
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
add a comment |
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
1
1
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
Thanks, it works. Now I have an error 500 but its an other problem. Thanks again.
– Arthur MICHEL
Nov 12 '18 at 10:16
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53259430%2fform-option-required-and-not-required%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown