I have a showSuccess page that requires some get variables, and on that page is a form. When the form submits to executeCreate() and there is an error, it calls the function setTemplate('show') and returns back to showSuccess. However, the get variables are missing.
开发者_如何学编程How do I keep the url the same?
You can get your GET variables from the sfWebRequest
object - something like the following should work):
public function executeCreate(sfWebRequest $request)
{
$getVars = $request->getGetParameters();
$qryString = http_build_query($getVars);
// ...some form creation and binding
if (!$form->isValid())
{
$this->redirect("module/show?" . $qryString);
}
}
You probably also need these in your form in the template. Use the relevant parts of the above code in your show action, set them to the view as you would any other variable and use them in the form action parameter:
<form method="post" action="<?php echo url_for("module/create?" . $qryString); ?>">
</form>
精彩评论