@@ -31,21 +31,30 @@ abstract class FormPage extends FrontendPage
3131 /**
3232 * {@inheritdocs}
3333 *
34- * @param RouteInfo|null $route_info
35- * @param array $route_data
36- * @return Response
34+ * @param ContainerInterface $container
3735 */
38- public function process ( RouteInfo $ route_info = null , $ route_data = [] )
36+ public function __construct ( ContainerInterface $ container )
3937 {
40- $ this -> route_info = $ route_info ;
38+ parent :: __construct ( $ container ) ;
4139
4240 $ this ->templateData += [
4341 'form ' => FAPI \FormBuilder::getForm ([$ this , 'getFormDefinition ' ])
4442 ->setValidate ([ [$ this , 'formValidate ' ] ])
4543 ->setSubmit ([ [$ this , 'formSubmitted ' ] ]),
4644 ];
45+
4746 $ this ->processFormSubmit ();
47+ }
4848
49+ /**
50+ * {@inheritdocs}
51+ *
52+ * @param RouteInfo|null $route_info
53+ * @param array $route_data
54+ * @return Response
55+ */
56+ public function process (RouteInfo $ route_info = null , $ route_data = [])
57+ {
4958 return parent ::process ($ route_info , $ route_data );
5059 }
5160
@@ -54,7 +63,7 @@ public function process(RouteInfo $route_info = null, $route_data = [])
5463 *
5564 * @return void
5665 */
57- private function processFormSubmit ()
66+ protected function processFormSubmit ()
5867 {
5968 $ this ->getApp ()->event ('before_form_process ' , ['form ' => $ this ->templateData ['form ' ]]);
6069 $ this ->templateData ['form ' ]->process ();
@@ -67,13 +76,21 @@ private function processFormSubmit()
6776 */
6877 protected function beforeRender ()
6978 {
70- if ($ this ->templateData ['form ' ]->isSubmitted ()) {
79+ if ($ this ->templateData ['form ' ] && $ this -> templateData [ ' form ' ] ->isSubmitted ()) {
7180 $ this ->getApp ()->event ('form_submitted ' , ['form ' => $ this ->templateData ['form ' ]]);
7281 return $ this ->templateData ['form ' ]->getSubmitResults (get_class ($ this ).'::formSubmitted ' );
7382 }
7483 return parent ::beforeRender ();
7584 }
7685
86+ /**
87+ * check if form is submitted
88+ */
89+ protected function isSubmitted ()
90+ {
91+ return ($ this ->templateData ['form ' ] && $ this ->templateData ['form ' ]->isSubmitted ());
92+ }
93+
7794 /**
7895 * gets form definition object
7996 *
0 commit comments