Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

@MisatoTremor
Copy link
Contributor

QA
Bug fix?no
New feature?yes
BC breaks?no
Deprecations?no
Tests pass?yes
Fixed tickets#13389
LicenseMIT
Doc PRsymfony/symfony-docs#4817

Replaces#15030

stephanvierkant and HeahDude reacted with thumbs up emoji
@MisatoTremor
Copy link
ContributorAuthor

For the upcoming hack day and if you find the time to review this for any issues I should fix, a short notice about that would be nice.

<tagname="form.type" />
</service>
<serviceid="form.type.dateinterval"class="Symfony\Component\Form\Extension\Core\Type\DateIntervalType">
<tagname="form.type"alias="dateinterval" />
Copy link
Member

Choose a reason for hiding this comment

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

Thealias attribute is now not needed anymore.

@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from95037ca to3586785CompareMarch 13, 2016 17:46
@MisatoTremor
Copy link
ContributorAuthor

Type alias removed and rebased.

@xabbuh Sorry for being late...

@fabpot
Copy link
Member

👍

<serviceid="form.type.datetime"class="Symfony\Component\Form\Extension\Core\Type\DateTimeType">
<tagname="form.type" />
</service>
<serviceid="form.type.dateinterval"class="Symfony\Component\Form\Extension\Core\Type\DateIntervalType">
Copy link
Contributor

Choose a reason for hiding this comment

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

A service for this type is not needed as it has no dependency, we just use FQCN since 2.8. Btw almost all the others have been deprecated in 3.1.

@HeahDude
Copy link
Contributor

Apart some very minor comments, this PR looks awesome!

@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from3586785 to77eff03CompareJune 17, 2016 09:23
@MisatoTremor
Copy link
ContributorAuthor

@HeahDude Thanks for your comments. Some of these stem from the fact that this PR was originally based on 2.7. I have updated it accordingly for 3.1+ now.

The in-linings would break the soft limit, so I left them out.

@fabpot
Copy link
Member

Can you inline even if it breaks the soft limit? We are not following any limits for line length.

@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from77eff03 to39ac6deCompareJune 17, 2016 10:15
@MisatoTremor
Copy link
ContributorAuthor

@fabpot OK, done :)

private $fields;

/**
* Constructor.
Copy link
Member

Choose a reason for hiding this comment

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

should be removed

@MisatoTremor
Copy link
ContributorAuthor

@xabbuh I did this in sync with the existing classes, i.e.DateTimeToArrayTransformer. Should I really change it only for this one (now)?

@fabpot
Copy link
Member

@MisatoTremor Let's do the change for this one for now.

@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from39ac6de to2f8f79dCompareJune 21, 2016 14:40
@MisatoTremor
Copy link
ContributorAuthor

@fabpot Done :)

throw new TransformationFailedException(sprintf('The fields "%s" should not be empty', implode('", "', $emptyFields)));
}
if (isset($value['invert']) && !is_bool($value['invert'])) {
throw new UnexpectedTypeException($value['invert'], 'boolean');
Copy link
Member

Choose a reason for hiding this comment

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

The resulting error message won't help the end user as 'invert' won't be anywhere, right?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

I don't quite understand what you mean with "won't be anywhere".

Copy link
Member

Choose a reason for hiding this comment

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

The error message is going to beExpected argument of type "boolean", xxx" given. I don't think there will be anything in the context mentioning that the error comes from theinvert value and not the whole value for the form.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

You are right, I oversaw this when applying HeahDudes comments. Fixed

@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from2f8f79d to43ad054CompareJune 22, 2016 11:46
Also add dateinterval widget to twig templates.
@MisatoTremorMisatoTremorforce-pushed theadd_dateinterval_type_3_1 branch from43ad054 tof7669beCompareJune 22, 2016 11:52
@fabpot
Copy link
Member

Thank you@MisatoTremor.

@fabpotfabpot merged commitf7669be intosymfony:masterJun 22, 2016
fabpot added a commit that referenced this pull requestJun 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#4817Replaces#15030Commits-------f7669be [Form] Add a DateInterval form type Also add dateinterval widget to twig templates.
public function __construct(array $fields = null, $pad = false)
{
if (null === $fields) {
$fields = array('years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert');
Copy link
Contributor

Choose a reason for hiding this comment

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

I would use an associative array here instead of plain array (because you often usearray_flip, andisset($array[$key]) is faster thanin_array($key, $array))

@MisatoTremor
Copy link
ContributorAuthor

Thanks all for your help improving this and thanks for merging.

$fields = array('years', 'months', 'days', 'hours', 'minutes', 'seconds', 'invert');
}
$this->fields = $fields;
$this->pad = (bool) $pad;
Copy link
Member

Choose a reason for hiding this comment

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

@MisatoTremor We're missing the actualpad property at the top of this class

xabbuh added a commit to xabbuh/symfony that referenced this pull requestJul 10, 2016
fabpot added a commit that referenced this pull requestJul 11, 2016
This PR was merged into the 3.2-dev branch.Discussion----------[Form][#16809] add missing pad property| Q             | A| ------------- | ---| Branch?       | master| Bug fix?      | yes| New feature?  | no| BC breaks?    | no| Deprecations? | no| Tests pass?   | yes| Fixed tickets |#16809 (comment)| License       | MIT| Doc PR        |Commits-------647e6ba [#16809] add missing pad property
@fabpotfabpot mentioned this pull requestOct 27, 2016
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

No reviews

Assignees

No one assigned

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

8 participants

@MisatoTremor@fabpot@HeahDude@weaverryan@Taluu@xabbuh@javiereguiluz@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp