Skip to content

[Form][FrameworkBundle][Bridge] Add a DateInterval form type #15030

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

Closed

Conversation

MisatoTremor
Copy link
Contributor

Q A
Bug fix? no
New feature? yes
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #13389
License MIT
Doc PR symfony/symfony-docs#4817

Replaces #13390

@webmozart webmozart added the Form label Jun 22, 2015
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is the header copied from other files?

i think you should be named here @MisatoTremor

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is the standard copyright header.
I've put my name at the class author PHPDoc as usual. ;)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, i didn't know.

thank you!

@jewome62
Copy link
Contributor

jewome62 commented Oct 5, 2015

🆒 !!!

When that will be integrated into the 2.8?

throw new TransformationFailedException('Expected a string.');
}
try {
if ($this->isISO8601($value)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, this if/else should be outside the try/catch, avoiding the need to catch TransformationFailedException as is (and it should use an early return)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, makes absolute sense to put it outside.
But is it really OK to just return null if the value is something the transformer does not expect?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@stof
Just saw again that this throw > catch > throw pattern is also used in DateTimeToStringTransformer. Most probably I got it originally from there.

So maybe both should be changed (DateTimeToStringTransformer in another PR then) or just be left as is.

What do you think?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Simplifying the DateTimeToStringTransformer in another PR makes sense yeah. but it should indeed be a separate PR

@MisatoTremor MisatoTremor force-pushed the add_dateinterval_type_2_8 branch from b7498b3 to 8045bc5 Compare October 14, 2015 08:30
Also add dateinterval widget to twig templates.
@MisatoTremor MisatoTremor force-pushed the add_dateinterval_type_2_8 branch from 0d8f42e to f235fef Compare October 14, 2015 09:55
@MisatoTremor
Copy link
Contributor Author

@stof Ok, simplified the transformer and also moved the format check out of the try/catch as this also was a throw > catch > throw.
Also fixed the deprecated form type by string name references and squashed commits.

AppVeyor build failure seems because of something else, as it also fails for the same tests in other PRs, etc. and Form component test passes.

class DateIntervalToArrayTransformer implements DataTransformerInterface
{
private $fields;
private $availableFields = array(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MisatoTremor
Copy link
Contributor Author

Rebased on master

fabpot added a commit that referenced this pull request Jun 22, 2016
…m type (MisatoTremor)

This PR was merged into the 3.2-dev branch.

Discussion
----------

[Form][FrameworkBundle][Bridge] Add a DateInterval form type

| Q             | A
| ------------- | ---
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #13389
| License       | MIT
| Doc PR        | symfony/symfony-docs#4817

Replaces #15030

Commits
-------

f7669be [Form] Add a DateInterval form type Also add dateinterval widget to twig templates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants