-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
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
[#6431] changing "Simple Example" to use implode/explode #6581
[#6431] changing "Simple Example" to use implode/explode #6581
Conversation
mccullagh
commented
May 21, 2016
Q | A |
---|---|
Doc fix? | yes |
New docs? | no |
Applies to | all |
Fixed tickets | #6431 |
I preferred to use |
@@ -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 | |||
Simple Example: transforming labels string from User 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 be Transforming 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); |
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
to
495ca23
Compare
|
||
#. 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 displayed
to the user as a simple string, to make them easier to edit.
|
function ($originalDescription) { | ||
return preg_replace('#<br\s*/?>#i', "\n", $originalDescription); | ||
// transform array to string so the input 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 -> $labelsAsString
This 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.
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! |
|
||
$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 handle null
as an empty string, we could then remove the hint in master and make a PR to document it in empty_data
option for the text type (ref symfony/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 pushed 133a77c, 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 the TextType
means i need to remove the data_class
in 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 pass null
|
||
// ... | ||
class TaskType extends AbstractType | ||
{ | ||
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 the 2.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 simply text
(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 | |||
--------------------------------------------- |
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:
👍 If you don't have much time, we can fix @xabbuh's comments during the merge as well. |
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) { |
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
@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
-------------------------------------------------------------------- |
Looks perfect, 👍 ! |
👍 |
…(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 | #6431 Commits ------- 4b8a755 [#6431] changing "Simple Example" to use implode/explode
Thanks @mccullagh for writing this! I've merged this into the 2.3 branch via d042351 and made some minor improvements afterwards in c8f4583 . I'll now merge them into the newer branches and update the form type names. |
Thank you @wouterj and everyone who helped. |