@@ -59,25 +59,21 @@ protected function attached($presenter)
5959 {
6060 if ($ presenter instanceof Presenter) {
6161 $ name = $ this ->lookupPath (Presenter::class);
62-
6362 if (!isset ($ this ->getElementPrototype ()->id )) {
6463 $ this ->getElementPrototype ()->id = 'frm- ' . $ name ;
6564 }
65+ if (!$ this ->getAction ()) {
66+ $ this ->setAction (new Link ($ presenter , $ name . self ::NAME_SEPARATOR . 'submit ' ));
67+ }
6668
67- if (iterator_count ($ this ->getControls ()) && $ this ->isSubmitted ()) {
68- foreach ($ this ->getControls () as $ control ) {
69+ $ controls = $ this ->getControls ();
70+ if (iterator_count ($ controls ) && $ this ->isSubmitted ()) {
71+ foreach ($ controls as $ control ) {
6972 if (!$ control ->isDisabled ()) {
7073 $ control ->loadHttpData ();
7174 }
7275 }
7376 }
74-
75- if (!$ this ->getAction ()) {
76- $ this ->setAction (new Link ($ presenter , 'this ' , []));
77- $ signal = new Nette \Forms \Controls \HiddenField ($ name . self ::NAME_SEPARATOR . 'submit ' );
78- $ signal ->setOmitted ()->setHtmlId (FALSE );
79- $ this ['_ ' . Presenter::SIGNAL_KEY . '_ ' ] = $ signal ;
80- }
8177 }
8278 parent ::attached ($ presenter );
8379 }
@@ -100,11 +96,20 @@ public function isAnchored()
10096 protected function receiveHttpData ()
10197 {
10298 $ presenter = $ this ->getPresenter ();
99+ $ isPost = $ this ->getMethod () === self ::POST ;
100+
101+ $ action = $ this ->getAction ();
102+ if ($ action instanceof Link) {
103+ $ this [($ isPost ? '_ ' : '' ) . Presenter::SIGNAL_KEY ] =
104+ (new Nette \Forms \Controls \HiddenField ($ action ->getDestination ()))
105+ ->setOmitted ()->setHtmlId (FALSE );
106+ $ this ->setAction (new Link ($ presenter , 'this ' ));
107+ }
108+
103109 if (!$ presenter ->isSignalReceiver ($ this , 'submit ' )) {
104110 return ;
105111 }
106112
107- $ isPost = $ this ->getMethod () === self ::POST ;
108113 $ request = $ presenter ->getRequest ();
109114 if ($ request ->isMethod ('forward ' ) || $ request ->isMethod ('post ' ) !== $ isPost ) {
110115 return ;
0 commit comments