21297 Posts in 5734 Topics by 2603 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 250 Views |
-
SS3 How to use a form as LeftAndMain

31 July 2012 at 9:14am
Perhaps someone could outline what needs to be done to use a simple form as a custom LeftAndMain.
What I've tried so far is to extend LeftAndMain and override getEditForm() where I have a single action like new FormAction('doMailingForm', 'Send'). It shows the form all right. I have it all added to $allowed_actions and it goes to doMailingForm method after submitting.
But now, I'd like to return to the same form with a confirmation message. What do I then do in doMailingForm() method that services the form submission?
This just gives me blank page:
public function doMailingForm($data, $form) {
$form->sessionMessage('Wysłano
' . time(), 'good');
Controller::curr()->getRequest()->addHeader('X-Pjax', 'Content'); // Force a content refresh
return Controller::curr()->redirect($this->Link());
} -
Re: SS3 How to use a form as LeftAndMain

31 July 2012 at 9:25pm Last edited: 31 July 2012 9:26pm
Two thoughts:
1. Inside a Form, I usually do$this->controller->redirect($this->Link());
return;
Since you are already inside a Controller you can try$this->redirect($this->Link());
return;
orController::curr()->redirect($this->Link());
return;2. You are using Polish strings. Are you encoding your php files as UTF? In that case check if your file starts with an (invisible) byte order mark. If so, remove it, since it can cause weird bugs.
Looking at the code in SilverStripe, in a Controller they sometimes use:
$form->sessionMessage($msg, 'good');
return $this->getResponseNegotiator()->respond($this->request);
and in a form:$this->sessionMessage($msg, 'good');
$this->controller->redirect($target);In LeftAndMain they often use the getResponseNegotiator approach, so maybe try that.
-
Re: SS3 How to use a form as LeftAndMain

31 July 2012 at 9:29pm
I'll try returning void instead of what redirect() returns, thanks for the suggestion.
Using responseNegotiator is also something I missed while looking through SS code, I'll try that
As to UTF-8, I'm sure it's all right. I'm using Netbeans IDE (it's even better for PHP that it is for Java), so I got such stuff covered.
| 250 Views | ||
|
Page:
1
|
Go to Top |

