Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[#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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
mccullagh commentedMay 21, 2016
| Q | A |
|---|---|
| Doc fix? | yes |
| New docs? | no |
| Applies to | all |
| Fixed tickets | #6431 |
mccullagh commentedMay 21, 2016
I preferred to use |
cookbook/form/data_transformers.rst Outdated
| won't be applied to that field. | ||
| Simple Example:Sanitizing HTML onUser Input | ||
| Simple Example:transforming labels string fromUser Input to array |
There was a problem hiding this comment.
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
cookbook/form/data_transformers.rst Outdated
| public function buildForm(FormBuilderInterface $builder, array $options) | ||
| { | ||
| $builder->add('description',TextareaType::class); | ||
| $builder->add('labels',TextType::class); |
There was a problem hiding this comment.
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?
cad6fce to495ca23Comparecookbook/form/data_transformers.rst Outdated
| #. 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. |
There was a problem hiding this comment.
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 commentedMay 21, 2016
|
cookbook/form/data_transformers.rst Outdated
| function ($originalDescription) { | ||
| returnpreg_replace('#<br\s*/?>#i',"\n", $originalDescription); | ||
| // transformarray tostring so theinput reads easier | ||
| function ($originalLabels) { |
There was a problem hiding this comment.
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 -> $labelsAsStringThis is just a proposal. Please don't make any change until our doc managers approve/reject this idea. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
I like your proposal
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
wouterj commentedMay 21, 2016
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! |
javiereguiluz commentedMay 21, 2016
cookbook/form/data_transformers.rst Outdated
| $builder->add( | ||
| $builder->create('description',TextareaType::class) | ||
| $builder->create('description',TextType::class) |
There was a problem hiding this comment.
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)?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You can still passnull
cookbook/form/data_transformers.rst Outdated
| public function buildForm(FormBuilderInterface $builder, array $options) | ||
| { | ||
| $builder->add('description',TextareaType::class); | ||
| $builder->add('tags',TextType::class); |
There was a problem hiding this comment.
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)?
| won't be applied to that field. | ||
| Simple Example:Sanitizing HTML onUser Input | ||
| --------------------------------------------- |
There was a problem hiding this comment.
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 commentedMay 21, 2016
👍 If you don't have much time, we can fix@xabbuh's comments during the merge as well. |
mccullagh commentedMay 21, 2016
I have not added a label to be BC with the old headline. I'm not sure how it should be in reStructuredText. |
cookbook/form/data_transformers.rst Outdated
| function ($originalDescription) { | ||
| returnpreg_replace('#<br\s*/?>#i', "\n", $originalDescription); | ||
| // transformarray tostring so theinput reads easier | ||
| function ($originalTags) { |
There was a problem hiding this comment.
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 commentedMay 21, 2016 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
@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-------------------------------------------------------------------- |
wouterj commentedMay 21, 2016
Looks perfect, 👍 ! |
xabbuh commentedMay 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 commentedMay 21, 2016
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 commentedMay 21, 2016
Thank you@wouterj and everyone who helped. |