Login | Forgot password | Register
What is OpenID?
OpenID is an Internet-wide identity system that allows you to sign in to many websites with a single account.
With OpenID, your ID becomes a URL (e.g. http://username.myopenid.com/). You can get a free OpenID for example from myopenid.com.
For more information visit the official OpenID site.
Archive
SilverStripe Forums » Archive » What's the correct way to publish a view after a form post.
Our old forums are still available as a read-only archive.
|
Page:
1
|
Go to End | |
| Author | Topic: What's the correct way to publish a view after a form post. | 258 Views |
-
What's the correct way to publish a view after a form post.

1 November 2008 at 3:42am
Hi,
I'm wondering what the correct method ist to publish a different view after a form post. My use case: I want to filter a view via a form. I currently have this code:
function FilterForm() {
//...
$actions = new FieldSet(
new FormAction( "filter", _t('UserDefinedForm.FILTER', 'Filtern') )
);//...
return new Form( $this, "FilterForm", $fields, $actions );
}function filter($data, $form) {
$ids = $this->someComplicatedFiltering($data);
$_GET["ids"] = $ids;
return Director::direct($this->data()->URLSegment."//select");
}function select() {
return array("FilteredIds" => $_GET["ids"]);
}It works, but I don't think it's nice because the Director starts from the very beginning.
I tried to make this work:
$this->pushCurrent();
$controller = new ModelAsController();
$request = new HTTPRequest("GET", $this->data()->URLSegment.'//preview', $request->getVars(), $request->postVars());
$request->match('$URLSegment//$Action/$ID/$OtherID');$result = $controller->handleRequest($request);
$this->popCurrent();
return $result->getBody();But this didn't work, it always showed me the default view of the object. I traced this to a code segment, where the request url (object_urlsegment/view) is "pushed" so it's object_urlsegment/object_urlsegment/view (I don't understand the use case of that).
So finally my question: What is the correct method to do this? There are two versions of this use case: Fetch a different view of the current object or fetch a view of a different object.
Thanks for your clarification,
Cheers,
Andy
| 258 Views | ||
|
Page:
1
|
Go to Top |
Currently Online: Euphemismus, tbarho
Welcome to our latest member: fearofbuttons

