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

add cookbook entry on creating dynamic forms based on services#1842

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

Closed
khepin wants to merge7 commits intosymfony:masterfromkhepin:dynamic_forms

Conversation

khepin
Copy link
Contributor

No description provided.


.. code-block:: php

private $security_context;
Copy link
Member

Choose a reason for hiding this comment

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

Please use camelCased variable names

@khepin
Copy link
ContributorAuthor

Needs to check the php version of the configuration.

context, or by defining it as a service. This is the option we will show here.

To define your form as a service, you simply add the configuration to your
``config.yml`` file.
Copy link
Member

Choose a reason for hiding this comment

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

Because you use different formats you can't use a specific extension in your text. Use something like '... add the confguration to your configuration file.' And add file comments in all code blocks below:

yaml file# app/config/config.ymlxml file<!-- app/config/config.xml -->php file// app/config/config.php

@weaverryan
Copy link
Member

Hi Sebastien!

Cool, a whole new entry! :) First thing though, how do you see this as different/similar tohttp://symfony.com/doc/current/cookbook/form/dynamic_form_generation.html?

If it's not different, should we combine the entries? Was the existing article not easy enough to find (<-- this is very possible). Also, the existing entry uses a subscriber (i.e. a whole other class for the listener), whereas your entry uses an anonymous function. I wouldmuch rather show the user how to do this using an anonymous function, and then just mention that this logic could also be in its own class. So, at the very least, that's one piece of your entry that I think we definitely need to integrate.

Let me know what you think and we'll go from there! I think this is a very important topic, so I would like to get this done well.

Thanks!

@khepin
Copy link
ContributorAuthor

I have merged the two articles.

I have added another section for some more advanced use of the form events and dynamic generation. In that last case, using closures wouldn't make sense. So I think it's good to keep both on the cookbook entry so users know what are the different options.

$form = $event->getForm();
$userId = $user->getId();

$form_options = [
Copy link
Member

Choose a reason for hiding this comment

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

It is better to use the backwards comtable way of defining PHP arrays instead of the PHP5.4 way:

$form_options = array(    ...,);

@weaverryan
Copy link
Member

Hey Sebastien!

This is a very complete example :). But I have a few questions first!

  1. I still think we have some repetition between the original part of this entry and your part. The first part talks about using posted data to dynamically change the form. You talk about this as well - and also show using auserId instead of the submitted data. I think we need to merge the two examples - there should probably only be one example using thePRE_SET_DATA in this way.

  2. There are some whitespace differences as well in the file - probably due to line break differences.

  3. Merging the 2 parts of this entry may solve it, but we may have too many other details. For example, showing the user how to register a form as a service and use it in the controller should be here. The goal is to be as "dense" with new information as possible (while still making it a full "story"). The less other details, the more we can get the "meat" of this entry across to the user. Nobody actually likes reading - so shorter = better ;)

Thanks!

@wouterj
Copy link
Member

ping@khepin

@khepin
Copy link
ContributorAuthor

Yikes, been a while!
I removed the parts of the article that duplicate something that is explained elsewhere.

I kept all the examples as I feel they fit different use cases and sticking all of them together would create confusion.

Let me know what you think.

@weaverryan
Copy link
Member

Hey Sebastien!

Thanks for the updates on this, I've finally just merged it into the 2.1 branch. I'll have another PR coming shortly with some tweaks as I wanted to re-read this big chapter anyways.

Thanks!

weaverryan added a commit that referenced this pull requestMar 30, 2013
weaverryan added a commit that referenced this pull requestApr 4, 2013
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

4 participants
@khepin@weaverryan@wouterj@stof

[8]ページ先頭

©2009-2025 Movatter.jp