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

[#6431] changing "Simple Example" to use implode/explode#6581

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

Conversation

mccullagh
Copy link
Contributor

QA
Doc fix?yes
New docs?no
Applies toall
Fixed tickets#6431

wouterj reacted with hooray emoji
@mccullagh
Copy link
ContributorAuthor

I preferred to uselabelsand nottags.

@@ -16,24 +16,24 @@ to render the form, and then back into a ``DateTime`` object on submit.
When a form field has the ``inherit_data`` option set, Data Transformers
won't be applied to that field.

Simple Example:Sanitizing HTML onUser Input
Simple Example:transforming labels string fromUser Input to array
Copy link
Contributor

Choose a reason for hiding this comment

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

Should beTransforming Labels String from User Input to Array


// ...
class TaskType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('description',TextareaType::class);
$builder->add('labels',TextType::class);
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't this go on 2.3?

@mccullaghmccullaghforce-pushed thefeature/data_transforming_example branch fromcad6fce to495ca23CompareMay 21, 2016 10:14

#. Your users are allowed to use *some* HTML tags, but not others: you need a way
to call :phpfunction:`strip_tags` after the form is submitted;
Internally we want to handle the ``labels`` as array, but to have the form simple we wanna allow the User to edit them as a string.

Choose a reason for hiding this comment

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

We don't use "we" in the docs. What if we reword this as:

Internally the labels are stored as an array, but they are displayedto the user as a simple string, to make them easier to edit.

@HeahDude
Copy link
Contributor

tags field is used elsewhere in the docs, we should keep it for consistency. What's the advantage of usinglabels?

function ($originalDescription) {
return preg_replace('#<br\s*/?>#i', "\n", $originalDescription);
// transform array to string so the input reads easier
function ($originalLabels) {

Choose a reason for hiding this comment

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

What if we rename these variables:

$originalLabels  -> $labelsAsArray$submittedLabels -> $labelsAsString

This is just a proposal. Please don't make any change until our doc managers approve/reject this idea. Thanks!

HeahDude reacted with confused emoji
Copy link
Member

Choose a reason for hiding this comment

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

I like your proposal

Copy link
Contributor

Choose a reason for hiding this comment

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

original/submitted keeps an "event" context, and I like that.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

original/submitted helps to identify the source of the Callbacks.

HeahDude reacted with thumbs up emoji
@wouterj
Copy link
Member

Looks great! I don't care much about labels vs tags. After you applied the open comments, I think it's ready to be merged. Thanks for working on this!

@mccullaghmccullagh changed the title[#6431] changing "Simple Example" to use implode/explode[WIP] [#6431] changing "Simple Example" to use implode/explodeMay 21, 2016
@javiereguiluz
Copy link
Member

@wouterj I think consistency is important here. As@HeahDude said, we usetags everywhere ... so I'm 👍 to replace labels by tags.

HeahDude reacted with thumbs up emoji


$builder->add(
$builder->create('description',TextareaType::class)
$builder->create('description',TextType::class)
Copy link
Contributor

Choose a reason for hiding this comment

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

Since text type is the default, I would suggest to remove the second argument everywhere to easy the merge in all branches.

Why not also add a tip to handlenull as an empty string, we could then remove the hint in master and make a PR to document it inempty_data option for the text type (refsymfony/symfony#18357)?

Copy link
Contributor

@HeahDudeHeahDudeMay 21, 2016
edited
Loading

Choose a reason for hiding this comment

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

I've pushed133a77c, this should really go on 2.3 imo.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

removing theTextTypemeans i need to remove thedata_classin the example too because else it would not be clear anymore which Type it is.

Copy link
Contributor

Choose a reason for hiding this comment

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

You can still passnull


// ...
class TaskType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder->add('description',TextareaType::class);
$builder->add('tags',TextType::class);
Copy link
Member

Choose a reason for hiding this comment

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

I agree that we should merge this into the2.3 branch first. You don't need to create a new PR for this (we can rebase when merging), but can you please change the type here to be simplytext (we will then update the type when merging things up)?

@@ -16,24 +16,24 @@ to render the form, and then back into a ``DateTime`` object on submit.
When a form field has the ``inherit_data`` option set, Data Transformers
won't be applied to that field.

Simple Example: Sanitizing HTML on User Input
---------------------------------------------
Copy link
Member

Choose a reason for hiding this comment

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

Can you please add a label to be BC with the old headline? This should look like this:

.. _simple-example-sanitizing-html-on-user-input:

@wouterj
Copy link
Member

👍

If you don't have much time, we can fix@xabbuh's comments during the merge as well.

@mccullagh
Copy link
ContributorAuthor

I have not added a label to be BC with the old headline. I'm not sure how it should be in reStructuredText.

function ($originalDescription) {
return preg_replace('#<br\s*/?>#i', "\n", $originalDescription);
// transform array to string so the input reads easier
function ($originalTags) {
Copy link
Contributor

Choose a reason for hiding this comment

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

You should revert the extra spaces here

@wouterj
Copy link
Member

wouterj commentedMay 21, 2016
edited
Loading

@mccullagh you do that by adding the line written by@xabbuh before the new headline. So you end up with this:

.. _simple-example-sanitizing-html-on-user-input:Simple Example: Transforming String Tags from User Input to an Array--------------------------------------------------------------------

@mccullaghmccullagh changed the title[WIP] [#6431] changing "Simple Example" to use implode/explode[#6431] changing "Simple Example" to use implode/explodeMay 21, 2016
@wouterj
Copy link
Member

Looks perfect, 👍 !

@xabbuh
Copy link
Member

👍

wouterj added a commit that referenced this pull requestMay 21, 2016
wouterj added a commit that referenced this pull requestMay 21, 2016
…(mccullagh)This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes#6581).Discussion----------[#6431] changing "Simple Example" to use implode/explode| Q             | A| ------------- | ---| Doc fix?      | yes| New docs?     | no| Applies to    | all| Fixed tickets |#6431Commits-------4b8a755 [#6431] changing "Simple Example" to use implode/explode
wouterj added a commit that referenced this pull requestMay 21, 2016
@wouterj
Copy link
Member

Thanks@mccullagh for writing this! I've merged this into the 2.3 branch viad042351 and made some minor improvements afterwards inc8f4583 . I'll now merge them into the newer branches and update the form type names.

@mccullagh
Copy link
ContributorAuthor

Thank you@wouterj and everyone who helped.

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.

5 participants
@mccullagh@HeahDude@wouterj@javiereguiluz@xabbuh

[8]ページ先頭

©2009-2025 Movatter.jp