New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Symfony multi-version compatibility #60
Conversation
* Fix polycollection in SF 2.8+ * Update checkbox grid for new choice lists * Tested in SF 2.3, 2.7, 2.8, 3.0, and 3.1
Looks good. I'll test this in our project (we're using PolyCollectionType) later. |
Sorry, i'm getting Exception when i send the form: Full Stack Trace
My FormType: class ArticleFormType extends AbstractType
{
/**
* {@inheritdoc}
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
// amoung other fields here ...
->add('segments', PolyCollectionType::class, [
'label' => 'Inhalt',
'types' => [
ArticleTextSegmentFormType::class,
ArticleVideoSegmentFormType::class,
],
'allow_add' => true,
'allow_delete' => true,
'prototype' => true,
'prototype_data' => [
'my_article_text_segment' => new ArticleTextSegment($article, $prototypeTextContent),
'my_article_video_segment' => new ArticleVideoSegment($article, $prototypeVideoContent),
],
])
// ...
}
} Tested with your compat repo @ Symfony 2.8.6 |
Looks like you have the _type set to the FQCN of the model class but I expected it to be set to the value of getBlockPrefix (see form-demo). I'll look for a way to keep BC here. In the meantime does your project work if you use getBlockPrefix there? Both with and without this PR? |
No, using the block prefix didn't work. And starting from Symfony 2.8 block names as types are deprecated. That's why we changed this in recent InfiniteFormBundle update.
Neither block names nor FQCN worked with your pull-request. |
The _type field is the hidden field in each row that identifies what kind of row it is. It doesn't have to represent an actual form type and we could have called it _key instead. In principle, its value is arbitrary. How would you feel if I made it truly arbitrary? Then you could keep the FQCN or choose any short string to identify it. It's used as the key of the prototypes array so it makes it easier to render the prototypes in Twig. (Also I just don't like putting FQCNs in my HTML. :) ) I'll see what I can do about prototype_data later. |
I'd like to see it remain arbitrary, not everyone will want to expose the
|
OK, new commit added. You can now use any string there. I had a look for the prototype_data option in the InfiniteFormBundle and it doesn't seem to exist as far as I can tell. Do you have a custom form extension that implements it? |
* Fix the polycollection type_name test * Tweak the checkbox grid test for better code coverage
Hi guys, is there a reason why this is not merged? |
I'll test it again. |
I was planning to update the docs before merging but I got sidetracked. I'll get it done in the next few days if there are no objections. |
There! Docs updated, PR merged, and BC maintained. |
Looks good. No more errors in our project with the new code. 👍 |
That's awesome - amazing job @jmclean |
Fixed polycollection in SF 2.8+. Prototypes are now indexed by getBlockPrefix() as intended.
Update checkbox grid for new choice lists. Choice lists were completely redone in SF 2.7 and then DoctrineChoiceLoader changed in 3.1.
Tested in SF 2.3, 2.7, 2.8, 3.0, and 3.1. See https://github.com/infinite-networks/form-demo/