Symfony embedded ChoiceType form updating every entity instance The Next CEO of Stack OverflowSymfony2 forms and <input> pattern attributePass/bind data objects to inner/embedded Symfony2 formsSymfony 2 forms - pass data to select without data class (no entity)Why the values are converted to an Array?translation-form with default entity translations not foundCan I get the choices in a symfony2 ChoiceType from a Choice Assert of the Entity?the image doesn't appeare on the web pageHow set null on field using symfony formSymfony 2.8 to 3.4: Simple array of entity IDs not savingHow to fill Smyfony CollectionType with N forms based on Database Rows

Natural language into sentence logic

How did people program for Consoles with multiple CPUs?

How can I open an app using Terminal?

Unreliable Magic - Is it worth it?

What makes a siege story/plot interesting?

Implement the Thanos sorting algorithm

Increase performance creating Mandelbrot set in python

Is it okay to store user locations?

What can we do to stop prior company from asking us questions?

Should I tutor a student who I know has cheated on their homework?

Why doesn't a table tennis ball float on the surface? How do we calculate buoyancy here?

How can I quit an app using Terminal?

How to make a software documentation "officially" citable?

How can I get through very long and very dry, but also very useful technical documents when learning a new tool?

Was a professor correct to chastise me for writing "Prof. X" rather than "Professor X"?

How do I go from 300 unfinished/half written blog posts, to published posts?

Is it my responsibility to learn a new technology in my own time my employer wants to implement?

Why do professional authors make "consistency" mistakes? And how to avoid them?

What does "Its cash flow is deeply negative" mean?

How should I support this large drywall patch?

Anatomically Correct Strange Women In Ponds Distributing Swords

How to start emacs in "nothing" mode (`fundamental-mode`)

How to write papers efficiently when English isn't my first language?

If I blow insulation everywhere in my attic except the door trap, will heat escape through it?



Symfony embedded ChoiceType form updating every entity instance



The Next CEO of Stack OverflowSymfony2 forms and <input> pattern attributePass/bind data objects to inner/embedded Symfony2 formsSymfony 2 forms - pass data to select without data class (no entity)Why the values are converted to an Array?translation-form with default entity translations not foundCan I get the choices in a symfony2 ChoiceType from a Choice Assert of the Entity?the image doesn't appeare on the web pageHow set null on field using symfony formSymfony 2.8 to 3.4: Simple array of entity IDs not savingHow to fill Smyfony CollectionType with N forms based on Database Rows










0















I have an EditAnnouncementType form which is embedded in a CollectionType form. The embedded form has two ChoiceType forms, one which properly updates the mapped Announcement entity. The other one however, will attempt to update all instances of the entity in my database, resulting in this error.




Type error: Argument 1 passed to AppBundleEntityAnnouncement::setType() must be of the type integer, null given, called in /Users/dperezpe/dev/grand-central/673/grand-central/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 528




EditAnnouncementType.php The type form is the error one.



public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('edit', SubmitType::class,
array
(
'label' => 'Save changes',
'attr' => ['class' => 'btn btn-primary']

))

->add('type', ChoiceType::class,
[
'choices' =>
[
'info_type' => 1,
'star_type' => 2,
'alert_type' => 3,
'lightbulb_type' => 4,
'event_type' => 5,
'statement_type' => 6,
'cat_type' => 7,
'hands_type' => 8
],
'expanded' => true,
'multiple' => false,
'required' => true,
'label_attr' => array(
'class' => 'sr-only'
),
])


->add('audience', ChoiceType::class,
[
'choices' =>
[
'Students: anybody with a student level field populated' => 'students',
'Employees: anybody with an employee ID number' => 'employees'
],
'expanded' => true,
'required' => true,
'multiple' => true
])


The CollectionType



public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add('announcements', CollectionType::class,
[
'entry_type' => EditAnnouncementType::class,
'entry_options' => ['label' => false],
]);


public function configureOptions(OptionsResolver $resolver)

$resolver->setDefaults([
'data_class' => AnnouncementManager::class
]);



I suspect it is related to the difference in the HTML name that was rendered to this, where the type inputs are missing an empty []



<input type="radio" 
id="announcement_edit_collection_announcements_221_type_0"
name="announcement_edit_collection[announcements][221][type]"
required="required" value="1">


<input type="checkbox" id="announcement_edit_collection_announcements_221_audience_0"
name="announcement_edit_collection[announcements][221][audience][]
"value="students">









share|improve this question
























  • The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

    – Jakub Matczak
    Mar 21 at 18:26












  • it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

    – d1596
    Mar 21 at 19:56











  • You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

    – xabbuh
    Mar 22 at 11:47











  • @xabbuh that was just to make sure it wasn't my form that was causing the error.

    – d1596
    Mar 22 at 15:59











  • @xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

    – d1596
    Mar 22 at 17:33















0















I have an EditAnnouncementType form which is embedded in a CollectionType form. The embedded form has two ChoiceType forms, one which properly updates the mapped Announcement entity. The other one however, will attempt to update all instances of the entity in my database, resulting in this error.




Type error: Argument 1 passed to AppBundleEntityAnnouncement::setType() must be of the type integer, null given, called in /Users/dperezpe/dev/grand-central/673/grand-central/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 528




EditAnnouncementType.php The type form is the error one.



public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('edit', SubmitType::class,
array
(
'label' => 'Save changes',
'attr' => ['class' => 'btn btn-primary']

))

->add('type', ChoiceType::class,
[
'choices' =>
[
'info_type' => 1,
'star_type' => 2,
'alert_type' => 3,
'lightbulb_type' => 4,
'event_type' => 5,
'statement_type' => 6,
'cat_type' => 7,
'hands_type' => 8
],
'expanded' => true,
'multiple' => false,
'required' => true,
'label_attr' => array(
'class' => 'sr-only'
),
])


->add('audience', ChoiceType::class,
[
'choices' =>
[
'Students: anybody with a student level field populated' => 'students',
'Employees: anybody with an employee ID number' => 'employees'
],
'expanded' => true,
'required' => true,
'multiple' => true
])


The CollectionType



public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add('announcements', CollectionType::class,
[
'entry_type' => EditAnnouncementType::class,
'entry_options' => ['label' => false],
]);


public function configureOptions(OptionsResolver $resolver)

$resolver->setDefaults([
'data_class' => AnnouncementManager::class
]);



I suspect it is related to the difference in the HTML name that was rendered to this, where the type inputs are missing an empty []



<input type="radio" 
id="announcement_edit_collection_announcements_221_type_0"
name="announcement_edit_collection[announcements][221][type]"
required="required" value="1">


<input type="checkbox" id="announcement_edit_collection_announcements_221_audience_0"
name="announcement_edit_collection[announcements][221][audience][]
"value="students">









share|improve this question
























  • The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

    – Jakub Matczak
    Mar 21 at 18:26












  • it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

    – d1596
    Mar 21 at 19:56











  • You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

    – xabbuh
    Mar 22 at 11:47











  • @xabbuh that was just to make sure it wasn't my form that was causing the error.

    – d1596
    Mar 22 at 15:59











  • @xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

    – d1596
    Mar 22 at 17:33













0












0








0


1






I have an EditAnnouncementType form which is embedded in a CollectionType form. The embedded form has two ChoiceType forms, one which properly updates the mapped Announcement entity. The other one however, will attempt to update all instances of the entity in my database, resulting in this error.




Type error: Argument 1 passed to AppBundleEntityAnnouncement::setType() must be of the type integer, null given, called in /Users/dperezpe/dev/grand-central/673/grand-central/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 528




EditAnnouncementType.php The type form is the error one.



public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('edit', SubmitType::class,
array
(
'label' => 'Save changes',
'attr' => ['class' => 'btn btn-primary']

))

->add('type', ChoiceType::class,
[
'choices' =>
[
'info_type' => 1,
'star_type' => 2,
'alert_type' => 3,
'lightbulb_type' => 4,
'event_type' => 5,
'statement_type' => 6,
'cat_type' => 7,
'hands_type' => 8
],
'expanded' => true,
'multiple' => false,
'required' => true,
'label_attr' => array(
'class' => 'sr-only'
),
])


->add('audience', ChoiceType::class,
[
'choices' =>
[
'Students: anybody with a student level field populated' => 'students',
'Employees: anybody with an employee ID number' => 'employees'
],
'expanded' => true,
'required' => true,
'multiple' => true
])


The CollectionType



public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add('announcements', CollectionType::class,
[
'entry_type' => EditAnnouncementType::class,
'entry_options' => ['label' => false],
]);


public function configureOptions(OptionsResolver $resolver)

$resolver->setDefaults([
'data_class' => AnnouncementManager::class
]);



I suspect it is related to the difference in the HTML name that was rendered to this, where the type inputs are missing an empty []



<input type="radio" 
id="announcement_edit_collection_announcements_221_type_0"
name="announcement_edit_collection[announcements][221][type]"
required="required" value="1">


<input type="checkbox" id="announcement_edit_collection_announcements_221_audience_0"
name="announcement_edit_collection[announcements][221][audience][]
"value="students">









share|improve this question
















I have an EditAnnouncementType form which is embedded in a CollectionType form. The embedded form has two ChoiceType forms, one which properly updates the mapped Announcement entity. The other one however, will attempt to update all instances of the entity in my database, resulting in this error.




Type error: Argument 1 passed to AppBundleEntityAnnouncement::setType() must be of the type integer, null given, called in /Users/dperezpe/dev/grand-central/673/grand-central/vendor/symfony/symfony/src/Symfony/Component/PropertyAccess/PropertyAccessor.php on line 528




EditAnnouncementType.php The type form is the error one.



public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('edit', SubmitType::class,
array
(
'label' => 'Save changes',
'attr' => ['class' => 'btn btn-primary']

))

->add('type', ChoiceType::class,
[
'choices' =>
[
'info_type' => 1,
'star_type' => 2,
'alert_type' => 3,
'lightbulb_type' => 4,
'event_type' => 5,
'statement_type' => 6,
'cat_type' => 7,
'hands_type' => 8
],
'expanded' => true,
'multiple' => false,
'required' => true,
'label_attr' => array(
'class' => 'sr-only'
),
])


->add('audience', ChoiceType::class,
[
'choices' =>
[
'Students: anybody with a student level field populated' => 'students',
'Employees: anybody with an employee ID number' => 'employees'
],
'expanded' => true,
'required' => true,
'multiple' => true
])


The CollectionType



public function buildForm(FormBuilderInterface $builder, array $options)

$builder->add('announcements', CollectionType::class,
[
'entry_type' => EditAnnouncementType::class,
'entry_options' => ['label' => false],
]);


public function configureOptions(OptionsResolver $resolver)

$resolver->setDefaults([
'data_class' => AnnouncementManager::class
]);



I suspect it is related to the difference in the HTML name that was rendered to this, where the type inputs are missing an empty []



<input type="radio" 
id="announcement_edit_collection_announcements_221_type_0"
name="announcement_edit_collection[announcements][221][type]"
required="required" value="1">


<input type="checkbox" id="announcement_edit_collection_announcements_221_audience_0"
name="announcement_edit_collection[announcements][221][audience][]
"value="students">






php symfony symfony-forms






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 21 at 18:22









Jakub Matczak

12.4k43650




12.4k43650










asked Mar 21 at 16:44









d1596d1596

858




858












  • The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

    – Jakub Matczak
    Mar 21 at 18:26












  • it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

    – d1596
    Mar 21 at 19:56











  • You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

    – xabbuh
    Mar 22 at 11:47











  • @xabbuh that was just to make sure it wasn't my form that was causing the error.

    – d1596
    Mar 22 at 15:59











  • @xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

    – d1596
    Mar 22 at 17:33

















  • The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

    – Jakub Matczak
    Mar 21 at 18:26












  • it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

    – d1596
    Mar 21 at 19:56











  • You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

    – xabbuh
    Mar 22 at 11:47











  • @xabbuh that was just to make sure it wasn't my form that was causing the error.

    – d1596
    Mar 22 at 15:59











  • @xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

    – d1596
    Mar 22 at 17:33
















The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

– Jakub Matczak
Mar 21 at 18:26






The type input misses empty [] because it doesn't allow multiple values (option 'multiple' => false,. So that's not the case.

– Jakub Matczak
Mar 21 at 18:26














it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

– d1596
Mar 21 at 19:56





it seems as though its an issue with my entity type field. As I switched the names for the two ChoiceType forms, and the same error throws

– d1596
Mar 21 at 19:56













You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

– xabbuh
Mar 22 at 11:47





You shouldn't change the name manually but enable the multiple option instead if you want to allow multiple values.

– xabbuh
Mar 22 at 11:47













@xabbuh that was just to make sure it wasn't my form that was causing the error.

– d1596
Mar 22 at 15:59





@xabbuh that was just to make sure it wasn't my form that was causing the error.

– d1596
Mar 22 at 15:59













@xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

– d1596
Mar 22 at 17:33





@xabbuh I don't want to enable multiple values, I just want to update that single entity the form should be mapped to

– d1596
Mar 22 at 17:33












0






active

oldest

votes












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
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285381%2fsymfony-embedded-choicetype-form-updating-every-entity-instance%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes















draft saved

draft discarded
















































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.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55285381%2fsymfony-embedded-choicetype-form-updating-every-entity-instance%23new-answer', 'question_page');

);

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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현