Skip to content

new cookbook article on using empty data for form classes #2415

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

Merged
merged 1 commit into from
Apr 4, 2013

Conversation

joelclermont
Copy link
Contributor

Q A
Doc fix? yes
New docs? yes (symfony/symfony#1140)
Applies to all
Fixed tickets #998

I'd like some feedback on my cookbook article for both accuracy and formatting. I am working on linking this cookbook article from the form class section of the documentation, as well as the two form types (choice and collection) that use the empty_data option. Those are both relevant, correct?


Option 1: instantiate a new class:

.. code-block:: php
Copy link
Member

Choose a reason for hiding this comment

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

Let me teach you some harder Shpinx formatting:

Instead of

lorem ipsum, see this example:

.. code-block:: php

    // ... some PHP code

You can use:

lorem ipsum, see the example::

    // ... some PHP code

(notice the double colon at the end). Both are rendered the same (as code defaults to PHP on Symfony.com) and we prefer the last one.

@joelclermont
Copy link
Contributor Author

Thanks for the feedback. I will send an updated PR shortly. I'll also include some of the additional documentation linking to this cookbook article.

@joelclermont
Copy link
Contributor Author

Ok, ready for another review. I've made the changes you requested and added a cross-reference link from the element-level empty_data section.

I didn't think it made sense to link from the form classes section. It didn't talk about getDefaultOptions() at all, so I thought it would be weird to mention this one option there. Let me know if this looks good.

@@ -11,3 +11,4 @@ Form
create_custom_field_type
create_form_type_extension
use_virtuals_forms
use_empty_data
Copy link
Member

Choose a reason for hiding this comment

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

you should add the newline at the end IMO to avoid extra diffs (and associated conflicts) when adding another line in the file

@stof
Copy link
Member

stof commented Mar 30, 2013

As there is nothing specific to the framework here, the Form component may be a better place than the cookbook. But it would also apply to the article about the virtual forms. @weaverryan what do you think ?

single: Form; Empty data

How to configure Empty Data for a Form Class
===============================================
Copy link
Member

Choose a reason for hiding this comment

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

some = to much

@weaverryan
Copy link
Member

@stof It's not always easy to write something that's useful that doesn't "couple" itself to the framework, but in this case, it's happened accidentally.

Buuut, we don't have the form component yet. So I think the only thing to do is keep it in the cookbook and move things later on.

@joelclermont
Copy link
Contributor Author

Fixed the missing line break at end of file and the extra = under the heading.


If you want to override this default behavior, there are two ways to do this.

**Option 1**: instantiate a new 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 think it's better to use sections in the article?

Option 1: Instantiate a new Class
---------------------------------

One reason you might use option 1 [...]

.. code-block:: php

     // ...

@wouterj
Copy link
Member

wouterj commented Apr 2, 2013

👍

weaverryan added a commit that referenced this pull request Apr 4, 2013
new cookbook article on using empty data for form classes
@weaverryan weaverryan merged commit e93ccf1 into symfony:2.0 Apr 4, 2013
@joelclermont joelclermont deleted the issue_998 branch April 4, 2013 01:27
weaverryan added a commit that referenced this pull request Apr 4, 2013
@weaverryan
Copy link
Member

Hi Joel!

Really really wonderful work here - and it's such a nice topic. I've merged this into the 2.0 branch and added some additional examples at sha: 87c0536. Please let me know if you see anything you don't like (and excuse my User -> Post change, I started adding details then only later saw that you were using a User example - both are perfectly fine).

I also merged this into the 2.1 branch and made the needed changes at sha: 0d62bfc

Thanks Joel!

@joelclermont
Copy link
Contributor Author

The additions look nice! Thanks for the merge.

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

Successfully merging this pull request may close these issues.

4 participants