Skip to content
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

Closed

Conversation

mccullagh
Copy link
Contributor

Q A
Doc fix? yes
New docs? no
Applies to all
Fixed tickets #6431

@mccullagh
Copy link
Contributor Author

I preferred to use labelsand not tags.

@@ -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
Copy link
Contributor

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);
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?

@mccullagh mccullagh force-pushed the feature/data_transforming_example branch from cad6fce to 495ca23 Compare May 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.
Copy link
Member

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.

@HeahDude
Copy link
Contributor

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

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

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!

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
Contributor Author

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
Copy link
Member

wouterj commented May 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!

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

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


$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 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)?

Copy link
Contributor

@HeahDude HeahDude May 21, 2016

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

removing the TextTypemeans i need to remove the data_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 pass null


// ...
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 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
---------------------------------------------
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

wouterj commented May 21, 2016

👍

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

@mccullagh
Copy link
Contributor Author

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 commented May 21, 2016

@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
--------------------------------------------------------------------

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

wouterj commented May 21, 2016

Looks perfect, 👍 !

@xabbuh
Copy link
Member

xabbuh commented May 21, 2016

👍

wouterj added a commit that referenced this pull request May 21, 2016
wouterj added a commit that referenced this pull request May 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 | #6431

Commits
-------

4b8a755 [#6431] changing "Simple Example" to use implode/explode
wouterj added a commit that referenced this pull request May 21, 2016
@wouterj
Copy link
Member

wouterj commented May 21, 2016

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.

@wouterj wouterj closed this May 21, 2016
@mccullagh
Copy link
Contributor Author

Thank you @wouterj and everyone who helped.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants