Form: Process request parameter _frameUpload

This parameter is being used to flag a request as form submission issued
by utilizing an iframe. Appending it to a form's action causes no redirection
to take place in case of successful submission and a reduced but still valid
layout to be printed in any way. Redirection must be handled by the client
regarding the meta tag "redirectUrl".

refs #8758
This commit is contained in:
Johannes Meyer 2015-07-21 15:22:24 +02:00
parent 0a9a066749
commit fc481e527b
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,10 @@
<html>
<head>
<?php if (isset($this->layout()->redirectUrl)): ?>
<meta name="redirectUrl" content="<?= $this->layout()->redirectUrl; ?>">
<?php endif ?>
</head>
<body>
<?= $this->render('inline.phtml'); ?>
</body>
</html>

View File

@ -946,12 +946,20 @@ class Form extends Zend_Form
$formData = $this->getRequestData();
if ($this->getUidDisabled() || $this->wasSent($formData)) {
if (($frameUpload = (bool) $request->getUrl()->shift('_frameUpload', false))) {
$this->getView()->layout()->setLayout('wrapped');
}
$this->populate($formData); // Necessary to get isSubmitted() to work
if (! $this->getSubmitLabel() || $this->isSubmitted()) {
if ($this->isValid($formData)
&& (($this->onSuccess !== null && false !== call_user_func($this->onSuccess, $this))
|| ($this->onSuccess === null && false !== $this->onSuccess()))) {
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
if (! $frameUpload) {
$this->getResponse()->redirectAndExit($this->getRedirectUrl());
}
$this->getView()->layout()->redirectUrl = $this->getRedirectUrl();
}
} elseif ($this->getValidatePartial()) {
// The form can't be processed but we may want to show validation errors though