oscarotero / form-manager

PHP library to create and validate html forms
MIT License
152 stars 42 forks source link

method to check if the form has been sent #48

Closed wtom closed 9 years ago

wtom commented 9 years ago

i only validate the form, if it was sent before. if i don't do it, all fields have errors on the first load.

if ($form->isSent() && $form->isValid()) { // save data }

oscarotero commented 9 years ago

Hi. Thanks for your contribution but I think this is not a good idea for some reasons:

I think each implementation should check whether the form has been sent or not in it's own way:

if (strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
    $form->loadFromGlobals();
    if ($form->isValid()) {
        //do stuff
    }
}