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

[Validator] Explained how to use array constant in annotation#10810

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

Closed

Conversation

@nikophil
Copy link
Contributor

Hi,

few days ago i tried to add a new feature to thechoice validator constraint, by adding a newchoicesFromConstant option.
symfony/symfony#29658
But then, i realized this was already supported.

I think this should be documented, as i think a lot of people don't know this feature.

thanks.

@HeahDudeHeahDude added Form Waiting Code MergeDocs for features pending to be merged labelsDec 27, 2018
@HeahDudeHeahDude added this to the4.3 milestoneDec 27, 2018
@HeahDudeHeahDude removed the Waiting Code MergeDocs for features pending to be merged labelDec 27, 2018
@HeahDudeHeahDude modified the milestones:4.3,3.4Dec 27, 2018
Copy link
Contributor

@HeahDudeHeahDude left a comment

Choose a reason for hiding this comment

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

Thank you very much for this contribution!

@nikophil
Copy link
ContributorAuthor

Hi@HeahDude
i think you know what i'm talking about here ;)

i've wondered if this would need aconfiguration-block and if we have to list all the other way to configure this, but i think it's really specific to the annotation...
what do you think ?

@nikophilnikophilforce-pushed thevalidator_choices_from_constant branch 2 times, most recently froma810dae to83a2304CompareDecember 27, 2018 12:37
Supplying the Choices from an Array Constant
--------------------------------------------

You can also directly provide an array constant to the ``choices`` option in the annotation::
Copy link
Contributor

Choose a reason for hiding this comment

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

- array constant+ constant containing an array

sounds a bit better


class Author
{
const GENRES = ['fiction', 'non-fiction'];
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 prefer sth likeaction andcomedy

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yep, i agree, but i've chosen these one for the coherence with the example above
would you mind that i change the other example as well ?


..note::

If the constant is stored in a different class, you can pass the fully qualified class name
Copy link
Contributor

Choose a reason for hiding this comment

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

s/stored/defined/

..note::

If the constant is stored in a different class, you can pass the fully qualified class name
of the class or import this class by adding it to the "use" list.
Copy link
Contributor

Choose a reason for hiding this comment

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

This line is not needed

@OskarStark
Copy link
Contributor

Thank you for your contribution 👍

@nikophilnikophilforce-pushed thevalidator_choices_from_constant branch from83a2304 to3f0ad71CompareDecember 27, 2018 14:50

..warning::

Notice that the constant in the option is used without quotes.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
Notice that the constant in the option is used without quotes.
The constant in the option is used without quotes.

HeahDude reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

👍

@HeahDudeHeahDude changed the titlevalidator : choice constraint : explain how to supply choices from an array constant[Validator] Explained how to use array constant in annotationJan 1, 2019
@nikophilnikophilforce-pushed thevalidator_choices_from_constant branch from3f0ad71 to9b23462CompareJanuary 2, 2019 13:29
}
}
Supplying the Choices from an Array Constant
Copy link
Contributor

Choose a reason for hiding this comment

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

array constant in lower case is better i think, wdyt?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

yes you're right

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

actually i've wrote like this, to be consistent with the title above which isSupplying the Choices with a Callback Function


..warning::

The constant in the option is used without quotes.
Copy link
Contributor

Choose a reason for hiding this comment

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

what about both inside note instead of warning? warning can be misunderstood

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

do you mean in thesame note or two different notes ?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

do you mean both inside thesame note ?

Copy link
Contributor

Choose a reason for hiding this comment

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

the same i think

@xabbuh
Copy link
Member

I wonder if it would not be easier to expand the code example that we have in the "Basic usage" section to also contain choices coming from a constant and adding an inline comment there.

@OskarStark
Copy link
Contributor

friendly ping@nikophil

@xabbuh's comment is a legitimate consideration 🤔

nikophil reacted with thumbs up emoji

@nikophil
Copy link
ContributorAuthor

hi@OskarStark sorry, i've forgotten this one, i was thinking it was merged.

here is some update.

@javiereguiluz
Copy link
Member

Nicolas, thanks for this contribution ... and sorry for the late merge!

javiereguiluz added a commit that referenced this pull requestMar 7, 2019
…ation (nikophil)This PR was squashed before being merged into the 3.4 branch (closes#10810).Discussion----------[Validator] Explained how to use array constant in annotationHi,few days ago i tried to add a new feature to the `choice` validator constraint, by adding a new `choicesFromConstant` option.symfony/symfony#29658But then, i realized this was already supported.I think this should be documented, as i think a lot of people don't know this feature.thanks.Commits-------7774aab [Validator] Explained how to use array constant in annotation
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@OskarStarkOskarStarkOskarStark approved these changes

@xabbuhxabbuhxabbuh approved these changes

+2 more reviewers

@HeahDudeHeahDudeHeahDude left review comments

@noniagriconomienoniagriconomienoniagriconomie left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

3.4

Development

Successfully merging this pull request may close these issues.

7 participants

@nikophil@OskarStark@xabbuh@javiereguiluz@HeahDude@noniagriconomie@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp