Description
Hi,
I thought about a new type of field type which can solve several problems i met on the user group.
The idea is to create an "hidden_entity" type which is just an hidden id in the form, and an entity fetched in the database by the DataTransformer. Here are two example of use:
The transport entity case
Imagine you have a comment which should be attached to an article. In the page, you'll maybe have your form posting to a special URL like /addComment/{article_id}, and then fetch back the article from the URL.
With hidden_entity, this would be way simplied since you'd just have to put the following on your comment form:
$builder->add('article', 'hidden_entity');
And populate if from the controller when rendering the form:
$comment->setArticle($current_viewing_article);
$form = $this->createForm(new CommentType(), $comment);
The "JS-UI" case
Just imagine you want your user to select something among a very large set of data, like a city, and use some complex JavaScript UI like autocompletion, dynamic map etc. The current symfony's entity will generate a containing the whole entries from the database, which is not acceptable in this case. Using hidden_entity, you can easily add an hidden id to your form and your free to do whatever you want to fill it. Hoping for feedbacks about this idea, I already wrote a prototype of this : https://github.com/Gregwar/FormBundle