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

Error Date on Form rendering (LogicException: Cannot use the "format" option of DateType when the html5 option is enabled) #400

Open
etiennerunge opened this issue Nov 19, 2024 · 0 comments

Comments

@etiennerunge
Copy link

Q A
Bug? yes
New Feature? no
Bundle Version 2.5.4
Sulu Version 2.6.5

Actual Behavior

Rendering Date (Symfony\Component\Form\Extension\Core\Type\DateType) doesn't work because of an error.

Expected Behavior

DateType should be rendered with default format without error

Steps to Reproduce

Add Date form field in form. This throws an error on page rendering: Cannot use the "format" option of "Symfony\Component\Form\Extension\Core\Type\DateType" when the "html5" option is enabled.

Possible Solutions

DateType field have by default html5 option value set to true.

But this is incompatible with the value of the format option set to IntlDateFormatter::LONG

// Sulu\Bundle\FormBundle\Dynamic\Types\DateType
        $type = TypeDateType::class;
        $translation = $field->getTranslation($locale);
        if ($translation && $translation->getOption('birthday')) {
            $type = BirthdayType::class;
        }
        $options['format'] = \IntlDateFormatter::LONG;
        $options['input'] = 'string';
        $builder->add($field->getKey(), $type, $options);

Could dateformat be configured in sulu form yaml config file, and html5 set to false?

Maybe this is relative to this issue : #49

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

1 participant