formers / former

A powerful form builder, for Laravel and other frameworks (stand-alone too)
https://formers.github.io/former/
1.34k stars 205 forks source link

Custom Rule classes not working #580

Open KuenzelIT opened 5 years ago

KuenzelIT commented 5 years ago

Hi!

This seems like dumb question, but are custom rule classes supported by Former?

I'm getting the following error when I try to pass my form request rules to Former:

strpos() expects parameter 1 to be string, object given

This happens in the Former.php file on line 315:

foreach ($expFieldRules as $rule) {
    $parameters = null;

    if (($colon = strpos($rule, ':')) !== false) {   // <-------------------
         $rulename = substr($rule, 0, $colon);
...
}

To me it seems like there's a check on rule objects missing.

Thanks!

stayallive commented 4 years ago

It is correct they currently give an error when used, they are indeed not supported by Former.

For now we will prevent errors (after #592 is merged) when passing Rule objects and in the future it's possible Former will support Rule classes.