adamwathan/form

Why there is no method validate to know if all form fields are "OK" ?

RobinDev opened this issue · 1 comments

Hello,

First, thanks for sharing your code.

I am interesting in your class but I am aksing me : Why there is no 'magic' function to check if all the form elements are valids.

Eg. :

<?php
//src/AdamWathan/Form/FormBuilder.php
namespace AdamWathan\Form;
...

    /**
     * Check if an error exist
     * @param mixed $name Null if you want to know if there is an error for all fields else 
     *                                      string corresponding to field name
     * @return bool
     */
    public function hasError($name = null)
    {
        if (! isset($this->errorStore)) {
            return false;
        }
        if ($name !== null) {
            return $this->errorStore->hasError($name);
        }

        return true;
    }
...

I am curious to know how you are doing.
Else, if you judge this new feature and modification relevant, I can submit a pull-request.

Thanks for your time.

I re-read the code and I see there is no form validator.

It's look like it's not the goal of this package. I will make a class wich wrap this one plus a validator class to avoid to define twice things like min, max...