Commit Graph

118 Commits

Author SHA1 Message Date
Johannes Meyer d1ea7e87a2 Improve form styling slightly 2014-10-15 15:46:07 +02:00
Eric Lippmann cc61dc2b01 Form: Don't override Zend_Form::setDefaults()
fixes #7315
2014-10-08 17:43:28 +02:00
Eric Lippmann 2956d9e342 form: Correctly set our default element decorators 2014-10-06 10:42:24 +02:00
Eric Lippmann bea110d0c7 Fix `Form::isSubmitted()' for dynamic submit labels 2014-09-19 14:27:04 +02:00
Eric Lippmann 5b5f553d0d form: Fix dynamic submit label retrieval 2014-09-19 13:39:38 +02:00
Eric Lippmann 3c9859a0f1 Call `Form::getSubmitLabal()' in `Form::addSubmitButton()'
This allows us to dynamically define submit labels in form subclasses.
2014-09-19 13:00:15 +02:00
Eric Lippmann 5ba96c32f9 `Form::setDefaults()' fix strict standards violation
Declaration of Icinga\Web\Form::setDefaults() should be compatible with that of Zend_Form::setDefaults().
2014-09-19 12:59:01 +02:00
Eric Lippmann 7eb51f6367 form/csrf: Set the csrf element decorators in the element not in the form 2014-09-19 12:57:53 +02:00
Johannes Meyer e7c021845d Simplify subform usage
refs #5525
2014-09-09 15:00:33 +02:00
Johannes Meyer f7f6bcc447 Make Form base class more test friendly..
refs #5525
2014-09-09 09:31:15 +02:00
Johannes Meyer c8ce1088c9 Disable checking whether a form is sent when form identification is disabled
refs #5525
2014-09-09 09:30:33 +02:00
Johannes Meyer 12b4865559 Fix incompatible declaration of Form::setDefaults()
PHP with strict standards: Declaration of Icinga\Web\Form::setDefaults()
should be compatible with that of Zend_Form::setDefaults()

refs #5525
2014-09-08 09:42:02 +02:00
Johannes Meyer 930e6e7d71 We shouldn't require Form::createElements() to return self
refs #5525
2014-09-08 09:24:53 +02:00
Johannes Meyer fc72ddfbc8 Adjust Preferences/GeneralForm to use handleRequest() &. Co.
refs #5525
2014-09-05 10:21:24 +02:00
Johannes Meyer 8846f17ae1 Make it possible to disable form identification
refs #5525
2014-09-05 09:16:09 +02:00
Johannes Meyer 54a834266c Form::createElements() should add elements instead of returning them
In case createElements() would still return the elements while requiring
the caller to add them to the form all form dependent configurations get
lost. (displaygroups, belongTo, ...) Wizards or parent forms can still
retrieve only input relevant fields by just calling createElements() and
getElements().

refs #5525
2014-09-03 12:21:31 +02:00
Johannes Meyer 95c839a8bd Remove remaining usages of the ElementWrapper- and HelpText-Decorator
refs #5525
2014-09-02 16:50:59 +02:00
Johannes Meyer 539ab91ffa Add the FormErrors decorator as default decorator for forms
This allows us to use Zend_Form::addError() to show error messages for
the entire form context.

refs #5525
2014-09-02 16:25:03 +02:00
Johannes Meyer 39bb01b433 Rename Icinga\Web\Form::onShow() to onRequest()
onShow() is misleading because at the time this method is being called the
form is neither shown nor created.

refs #5525
2014-09-02 16:19:45 +02:00
Eric Lippmann d4c4ab7b2c lib/form: Fix default element decorators but breaking noscript layout
Replaced `ElementWrapper' and `HelpText' with Zend's `HtmlTag' and `Label' respectively.

Instances of Zend_Form_Element returned by `Form::createElements()' now receive our desired default decorators.

refs #5525
2014-09-02 15:23:07 +02:00
Johannes Meyer cd8015f41a Pass the current form instance to the callback as second argument
refs #5525
2014-09-01 14:58:16 +02:00
Eric Lippmann 0822aff293 library/form: Fix return value of `getName()' not being filterd the first time it's called
`Form::getName()' auto-detects the form's name if it's not set and sets the form's name using `Zend_Form::setName()'.
`Zend_Form::setName()' then filters the form name stripping backslash '\' characters. The first call to `Form::getName()'
did not regard the filtering and thus returned the unfiltered name which led to `Form::wasSent()' returning `false'.

refs #5525
2014-09-01 14:40:45 +02:00
Eric Lippmann f3e74f0f24 library/form: Append class 'autosubmit' in case the element to autosubmit has the class attribute set
Before, the class attribute would've been overwritten.

refs #5525
2014-09-01 09:44:04 +02:00
Johannes Meyer 79b0ed64ec Make it possible to provide a closure to be called instead of onSuccess()
This allows us to write generic forms like the ConfirmRemoval form but to
utilize handleRequest() while providing a closure in the array that is passed
to a form's constructor.

refs #5525
2014-08-29 12:21:31 +02:00
Johannes Meyer bf23688e73 Make autosubmit work in non-JS enviroments
We require forms to set autosubmit=true on elements which are supposed
to be submitted automatically now. The base form then ensures that this
works in JS environments and non-JS environments as well by applying the
right changes to the HTML.

refs #5525
2014-08-29 09:08:53 +02:00
Johannes Meyer 486104d59e Check explictly for FALSE when calling onSuccess()
This allows us to just end onSuccess() without requiring it to return TRUE
to initiate redirection.

refs #5525
2014-08-29 09:04:20 +02:00
Johannes Meyer e1329058db Do not hard code the name of the form identification element
Like the csrf element name the form identification element name should
be publicly accessible as well.

refs #5525
2014-08-27 13:14:40 +02:00
Johannes Meyer 6783d51f76 A form is "submitted" when it was "sent" but no submit label was set
This enables us to use handleRequest() as is when no specific submit button
is required.

refs #5525
2014-08-27 10:28:50 +02:00
Johannes Meyer 0ff79b0948 Replace Form::onFailure() with Form::onShow()
There is currently no usecase for onFailure() but for onShow() wherewith
the case is covered when a form needs to be prepared before showing it
to the user while the form was not submitted in any way.

refs #5525
2014-08-27 10:25:50 +02:00
Johannes Meyer d3c2fc858c Access formdata internally using a public helper method
This way concrete form implementations can also simply fetch form
dependent request values without referring to the form's submission
method.

refs #5525
2014-08-27 10:19:33 +02:00
Johannes Meyer 65dd3f9a5b Make the form in view scripts accessible using $form instead of $element
refs #5525
2014-08-27 10:10:55 +02:00
Johannes Meyer 98b2bce15e Icinga\Web\Form::onSuccess() must not return TRUE
When using Icinga\Web\Form directly without creating a specific sub-class
and calling handleRequest() one must not get redirected.

refs #5525
2014-08-27 10:09:29 +02:00
Johannes Meyer 45cbd3f067 We do not require the request being passed to handleRequest()
refs #5525
2014-08-26 12:31:05 +02:00
Johannes Meyer 5c7999fe9b Forms should be responsible for any redirection as well
If no specific url has been set with setRedirectUrl() a form redirects to the
current action it was posted to.

refs #5525
2014-08-26 12:30:37 +02:00
Johannes Meyer 52534a2f46 It is a form's responsibility to process the request it was submitted with
How forms are being validated should not be a task that is part of the
controller action, but should be handled by the form base class as it is
most of the time the same procedure. Now a controller action just sets
up the form to use, calls handleRequest() and acts upon its return value.
(e.g. calling handleRequest() from another form or any redirection)

refs #5525
2014-08-25 17:06:45 +02:00
Johannes Meyer c93ab7951d Check whether a form's data was sent instead of whether it's complete
It is not sufficient to just check whether all required elements are being
submitted. We definetely need to check whether the submit button was
pressed. But doing this and providing a standard button with a static name
simultaneously will produce conflicts if forms are using the same action
urls. To fix this, we'll add an additional form-identification check by using
a form's name or class.

refs #5525
2014-08-25 16:49:54 +02:00
Johannes Meyer 7b221e2aba It should not be a form's responsibility how its submit button should look..
...in case it's a standard button. No need to be DRY here.

refs #5525
2014-08-22 15:20:54 +02:00
Johannes Meyer 2b879b344f Do not populate using createElements() and fix documentation blocks
refs #5525
2014-08-22 12:04:14 +02:00
Johannes Meyer 7311ab964e Do not set the full url from the request as action with form parameters
Setting an url with parameters named like form elements in a form with
method POST causes Zend to ignore any POST data because GET will be
processed with higher priority.

fixes #6806
2014-08-13 14:50:21 +02:00
Johannes Meyer e7da9c0a00 Make our anti CSRF logic being a form element
refs #5525
2014-08-12 14:43:10 +02:00
Johannes Meyer fe63ce664f Make use if 'ignore´ instead of explicitly unsetting array keys
refs #5525
2014-08-12 13:57:28 +02:00
Johannes Meyer 4b1169c0a1 Fix improper form submission
refs #5525
2014-08-12 10:41:19 +02:00
Johannes Meyer 8b2cc3a558 Do not consider <button type=submit> when checking form completion
refs #5525
2014-07-23 10:58:45 +02:00
Johannes Meyer 0bf0213547 Rename Form::addElement to Form::createElement
Since we are using mainly createElement and addElement is only an alias for
createElement if no object is passed our changes to addElement can safely
be moved to createElement.

refs #5525
2014-07-23 10:57:46 +02:00
Johannes Meyer 75e09f2c69 Do not consider submit buttons when checking form completion
refs #5525
2014-07-21 15:25:00 +02:00
Johannes Meyer f5ac592645 Do not consider disabled elements when checking form completion
Values of disabled inputs are not sent by browsers.

refs #5525
2014-07-21 08:57:41 +02:00
Johannes Meyer f4ff2c90f2 It's a form's responsibility how its submit button should look like
refs #5525
2014-07-18 09:54:36 +02:00
Johannes Meyer 6ac471c598 Also mention the viewscript functionality of Form::loadDefaultDecorators()
refs #5525
2014-07-18 09:52:50 +02:00
Johannes Meyer 8f0b9899a3 We cannot know what kind of data is passed to Form::isValid()
refs #5525
2014-07-18 09:52:05 +02:00
Johannes Meyer 78a6175acc Make form creation lazy and implement the new validation mechanism
Form creation must not depend on specific function calls. If a forms' elements are required and missing, create them. Form::isValid() must be
able to determine whether a form can be processed or not without to rely
on a particular button value.

refs #5525
2014-07-18 09:51:15 +02:00