File tree Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Expand file tree Collapse file tree 1 file changed +10
-12
lines changed Original file line number Diff line number Diff line change 17
17
use Symfony \Component \HttpKernel \Exception \UnprocessableEntityHttpException ;
18
18
use Symfony \UX \LiveComponent \Attribute \BeforeReRender ;
19
19
use Symfony \UX \LiveComponent \Attribute \LiveProp ;
20
+ use Symfony \UX \LiveComponent \Util \ArrayUtil ;
21
+ use Symfony \UX \TwigComponent \Attribute \PostMount ;
20
22
21
23
/**
22
24
* @author Ryan Weaver <[email protected] >
@@ -63,23 +65,19 @@ trait ComponentWithFormTrait
63
65
*/
64
66
abstract protected function instantiateForm (): FormInterface ;
65
67
66
- /**
67
- * Override in your class if you need extra mounted values.
68
- *
69
- * If you override, call $this->initializeFormValues() manually
70
- * and also $this->formView = $form if you are passing in a Form.
71
- *
72
- * TODO: Refactor to PostMount when available.
73
- * https://github.com/symfony/ux/pull/220
74
- */
75
- public function mount (FormView $ form = null )
68
+ #[PostMount]
69
+ public function postMount (array $ data ): array
76
70
{
77
- if ($ form ) {
78
- $ this ->formView = $ form ;
71
+ // allow the FormView object to be passed into the component() as "form"
72
+ if (array_key_exists ('form ' , $ data )) {
73
+ $ this ->formView = $ data ['form ' ];
74
+ unset($ data ['form ' ]);
79
75
}
80
76
81
77
// set the formValues from the initial form view's data
82
78
$ this ->initializeFormValues ();
79
+
80
+ return $ data ;
83
81
}
84
82
85
83
/**
You can’t perform that action at this time.
0 commit comments