Permalink
Browse files

Allow read-only fields when editing collections of entities.

  • Loading branch information...
1 parent f81ec77 commit 858d29c48223cfac07397545e7eb74bfc293f434 @Romain-Geissler Romain-Geissler committed May 14, 2012
Showing with 5 additions and 2 deletions.
  1. +4 −1 Admin/AdminHelper.php
  2. +1 −1 Controller/HelperController.php
View
@@ -85,16 +85,18 @@ public function getAdmin($code)
* @throws \RuntimeException
*
* @param \Sonata\AdminBundle\Admin\AdminInterface $admin
+ * @param object $subject
* @param string $elementId
*
* @return array
*/
- public function appendFormFieldElement(AdminInterface $admin, $elementId)
+ public function appendFormFieldElement(AdminInterface $admin, $subject, $elementId)
{
// retrieve the subject
$formBuilder = $admin->getFormBuilder();
$form = $formBuilder->getForm();
+ $form->setData($subject);
$form->bindRequest($admin->getRequest());
// get the field element
@@ -138,6 +140,7 @@ public function appendFormFieldElement(AdminInterface $admin, $elementId)
$data[$childFormBuilder->getName()][] = $value;
$finalForm = $admin->getFormBuilder()->getForm();
+ $finalForm->setData($subject);
// bind the data
$finalForm->setData($form->getData());
@@ -80,7 +80,7 @@ public function appendFormFieldElementAction(Request $request)
$admin->setSubject($subject);
- list($fieldDescription, $form) = $this->helper->appendFormFieldElement($admin, $elementId);
+ list($fieldDescription, $form) = $this->helper->appendFormFieldElement($admin, $subject, $elementId);
$view = $this->helper->getChildFormView($form->createView(), $elementId);

0 comments on commit 858d29c

Please sign in to comment.