Form: Show the form autosubmit warning in the header tag...

...and use a unique id for the progress element.

refs #8369
This commit is contained in:
Johannes Meyer 2015-08-21 11:40:38 +02:00
parent 89bc1f13ed
commit 747f6dcf77

View File

@ -669,7 +669,7 @@ class Form extends Zend_Form
{ {
$this->useFormAutosubmit = (bool) $state; $this->useFormAutosubmit = (bool) $state;
if ($this->useFormAutosubmit) { if ($this->useFormAutosubmit) {
$this->setAttrib('data-progress-element', 'form-header'); $this->setAttrib('data-progress-element', 'header-' . $this->getId());
} else { } else {
$this->removeAttrib('data-progress-element'); $this->removeAttrib('data-progress-element');
} }
@ -1206,13 +1206,16 @@ class Form extends Zend_Form
'form' => $this 'form' => $this
)); ));
} else { } else {
$this->addDecorator('Description', array('tag' => 'h1')); $this->addDecorator('Description', array('tag' => 'h1', 'escape' => !$this->getUseFormAutosubmit()))
if ($this->getUseFormAutosubmit()) { ->addDecorator(
$this->addDecorator('Autosubmit', array('accessible' => true)) 'HtmlTag',
->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'header', 'id' => 'form-header')); array(
} 'tag' => 'div',
'class' => 'header',
$this->addDecorator('FormDescriptions') 'id' => 'header-' . $this->getId()
)
)
->addDecorator('FormDescriptions')
->addDecorator('FormNotifications') ->addDecorator('FormNotifications')
->addDecorator('FormErrors', array('onlyCustomFormErrors' => true)) ->addDecorator('FormErrors', array('onlyCustomFormErrors' => true))
->addDecorator('FormElements') ->addDecorator('FormElements')
@ -1256,6 +1259,25 @@ class Form extends Zend_Form
return $name; return $name;
} }
/**
* Retrieve form description
*
* This will return the escaped description with the autosubmit warning icon if form autosubmit is enabled.
*
* @return string
*/
public function getDescription()
{
$description = parent::getDescription();
if ($description && $this->getUseFormAutosubmit()) {
$autosubmit = $this->_getDecorator('Autosubmit', array('accessible' => true));
$autosubmit->setElement($this);
$description = $autosubmit->render($this->getView()->escape($description));
}
return $description;
}
/** /**
* Set the action to submit this form against * Set the action to submit this form against
* *