@@ -716,11 +716,12 @@ public function it_renders_rest_of_the_form_until_specified_field()
716716 /** @test */
717717 public function it_can_add_child_form_as_field ()
718718 {
719- $ form = $ this ->formBuilder ->plain ();
719+ $ model = ['song ' => ['body ' => 'test body ' ], 'title ' => 'main title ' ];
720+ $ form = $ this ->formBuilder ->plain ([
721+ 'model ' => $ model ,
722+ ]);
720723 $ customForm = $ this ->formBuilder ->create ('CustomDummyForm ' );
721724 $ customForm ->add ('img ' , 'file ' )->add ('name ' , 'text ' , ['label_show ' => false ]);
722- $ model = ['song ' => ['body ' => 'test body ' ], 'title ' => 'main title ' ];
723- $ form ->setModel ($ model );
724725
725726 $ form
726727 ->add ('title ' , 'text ' , [
@@ -779,6 +780,20 @@ public function it_can_add_child_form_as_field()
779780 $ this ->fail ('No exception on bad method call on child form. ' );
780781 }
781782
783+ /** @test */
784+ public function it_can_use_model_property_to_set_value ()
785+ {
786+ $ form = $ this ->formBuilder ->plain ([
787+ 'model ' => $ this ->model ,
788+ ]);
789+
790+ $ form ->add ('alias_accessor ' , 'choice ' , [
791+ 'property ' => 'accessor ' ,
792+ ]);
793+
794+ $ this ->assertEquals ($ form ->alias_accessor ->getValue (), $ this ->model ->accessor );
795+ }
796+
782797 /** @test */
783798 public function it_reads_configuration_properly ()
784799 {
@@ -820,10 +835,11 @@ public function it_works_when_setModel_method_is_called()
820835 /** @test */
821836 public function it_removes_children_from_parent_type_fields ()
822837 {
823- $ form = $ this ->formBuilder ->plain ();
824- $ customForm = $ this ->formBuilder ->create ('CustomDummyForm ' );
825838 $ model = ['song ' => ['title ' => 'test song title ' , 'body ' => 'test body ' ], 'title ' => 'main title ' ];
826- $ form ->setModel ($ model );
839+ $ form = $ this ->formBuilder ->plain ([
840+ 'model ' => $ model ,
841+ ]);
842+ $ customForm = $ this ->formBuilder ->create ('CustomDummyForm ' );
827843
828844 $ form
829845 ->add ('title ' , 'text ' )
0 commit comments