Skip to content
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

Does not support full range of native FormTypes - Symfony 4.3.4 #23

Open
AndrewMacKay-base opened this issue Jan 29, 2020 · 1 comment

Comments

@AndrewMacKay-base
Copy link

AndrewMacKay-base commented Jan 29, 2020

I'm uncertain whether the issue I'm experiencing is because my current version of Symfony 4.3.4 is unsupported by this bundle, or due to some specific implementation issue in our installation, or whether actually the bundle does not support all the different types included by Symfony.

use Limenius\Liform\Resolver;
use Limenius\Liform\Liform;
use Limenius\Liform\Liform\Transformer;
...
public function edit(Activity $activity, Liform $liform, Request $request)
    {
    // $builder->add('startDate', DateType::class, [
    $form = $this->createForm(ActivityFormType::class, $activity, []);
    $schema = $liform->transform($form);
...
}

The above pattern works as expected for TextType, and ChoiceType, but falls over for DateType with the error

"Could not find a transformer for any of these types (date, form) "

The documenation does not make it clear whether I should expect this functionality to exist. It suggests I will need to add custom work to include custom extension, however seems to imply that it should work out the box with a standard Symfony install.

I notice that DateType and EntityType do not seem to be in the list of available transformers here.

https://github.com/Limenius/LiformBundle/blob/master/Resources/config/transformers.xml

Am I correct then in my understanding that DateType which is a standard Symfony type is not supported?
https://symfony.com/doc/current/reference/forms/types/date.html

Edit
Also from here http://nacho-martin.com/serializing-symfony-forms-to-json-schema.html
This overview seems to imply dates are supported
->add('dueTo', Type\DateTimeType::class, [
Using the DateTimeType we get a similar error Could not find a transformer for any of these types (datetime)

@phpwutz
Copy link
Contributor

phpwutz commented Mar 4, 2020

I'm facing the same problem, this was working fine in 0.13, but upgrading to 0.15 broke it.
I very much assume it's got something to do with this "fix": 8c54258

I've helped myself for now to restore the "old" behavior by adding custom transformers in services.yml:

services:
    app.liform.datetime_type.transformer:
        class: Limenius\Liform\Transformer\StringTransformer
        parent: Limenius\Liform\Transformer\AbstractTransformer
        tags:
            - { name: liform.transformer, form_type: datetime, widget: datetime }
    app.liform.date_type.transformer:
        class: Limenius\Liform\Transformer\StringTransformer
        parent: Limenius\Liform\Transformer\AbstractTransformer
        tags:
            - { name: liform.transformer, form_type: date, widget: date }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants