Hi Derek,
You mean by calling createForm twice ?
If so, how to render the forms in one single form element then ? Plus, when
having forms defined as services, this force you to create a specific
service just for the additional fields.
Don't know, but i think something is missing.
Take the following form build for instance :
// ArticleType
$builder
->add('title')
->add('photoFiles', new PhotosType())
;
// PhotosType
$builder
->add('photo1', 'file', array(
'type' => 'file',
))
->add('photo2', 'file', array(
'type' => 'file',
'required' => false,
))
->add('photo3', 'file', array(
'type' => 'file',
'required' => false,
))
;
And then in the controller :
$article = new Article();
$photoFiles = array(
'photo1' => null,
'photo2' => null,
'photo3' => null,
);
$form = $this->createForm(new ArticleType(), $article);
$form->get('photoFiles')->setData($photoFiles);
if ('POST' == $request->getMethod()) {
$form->bindRequest($request); // throws an error : Neither element
"photoFiles" nor method "setPhotoFiles()" exists in class
"Ano\TestBundle\Entity\Article"
}
It should be as simple as that, but it's not. Even if it's really great to
bind form data to an object, the form has nothing to do with the domain
model and should allow that, don't you think ?
Benjamin.
--
If you want to report a vulnerability issue on symfony, please send it to
security at symfony-project.com
You received this message because you are subscribed to the Google
Groups "symfony developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/symfony-devs?hl=en