Skip to content
Browse files

Bind entity in factory

  • Loading branch information...
1 parent b63526f commit 76dcbd6179b20549865cc219fe16b81c35a92b65 @weierophinney committed
Showing with 8 additions and 3 deletions.
  1. +2 −3 src/PhlyPeep/Controller/PeepController.php
  2. +6 −0 src/PhlyPeep/Model/PeepForm.php
View
5 src/PhlyPeep/Controller/PeepController.php
@@ -49,9 +49,8 @@ public function submitAction()
throw new \DomainException('Unknown authenticated user type encountered');
}
- $peep = new Model\PeepEntity();
- $form = Model\PeepForm::factory($peep);
- $form->bind($peep);
+ $peep = new Model\PeepEntity();
+ $form = Model\PeepForm::factory($peep);
$request = $this->getRequest();
$data = $request->getPost();
View
6 src/PhlyPeep/Model/PeepForm.php
@@ -12,6 +12,7 @@ public static function factory(PeepEntity $peep = null)
if (null === $peep) {
$peep = __NAMESPACE__ . '\PeepEntity';
}
+
$builder = new AnnotationBuilder();
$form = $builder->createForm($peep);
@@ -25,6 +26,11 @@ public static function factory(PeepEntity $peep = null)
'value' => 'Peep!',
),
));
+
+ if ($peep instanceof PeepEntity) {
+ $form->bind($peep);
+ }
+
return $form;
}
}

0 comments on commit 76dcbd6

Please sign in to comment.
Something went wrong with that request. Please try again.