public function createFormForObject(string $formclass)
    { 
        if (!is_a($formclass, BaseForm::class, true))
            throw new \InvalidArgumentException("Not a valid BaseForm class provided");

        $form = new Form($formclass);
        $refl = new \ReflectionClass($formclass);

        $field_validators = $formclass::listFieldValidators();
        $fields = $this->getAnnotatedFields($refl, $field_validators);
        foreach ($fields as $name => $field)
            $form->add($field);

        $this->addFormValidators($refl, [$formclass, 'listFormValidators'](), $form);
        return $form;
    }
public function createFormForObject(string $formclass)
    { 
        if (!is_a($formclass, BaseForm::class, true))
            throw new \InvalidArgumentException("Not a valid BaseForm class provided");

        $form = new Form($formclass);
        $refl = new \ReflectionClass($formclass);

        $field_validators = $formclass::listFieldValidators();
        $fields = $this->getAnnotatedFields($refl, $field_validators);
        foreach ($fields as $name => $field)
            $form->add($field);

        $this->addFormValidators($refl, [$formclass, 'listFormValidators'](), $form);
        return $form;
    }
public function createFormForObject ( string $ formclass ) { if ( ! is_a ( $ formclass , BaseForm :: class , true ) ) throw new \ InvalidArgumentException ( "Not a valid BaseForm class provided" ) ; $ form = new Form ( $ formclass ) ; $ refl = new \ ReflectionClass ( $ formclass ) ; $ field_validators = $ formclass :: listFieldValidators ( ) ; $ fields = $ this -> getAnnotatedFields ( $ refl , $ field_validators ) ; foreach ( $ fields as $ name => $ field ) $ form -> add ( $ field ) ; $ this -> addFormValidators ( $ refl , [ $ formclass , 'listFormValidators' ] ( ) , $ form ) ; return $ form ; }
Create a form using reflection on a POPO.

The class is inspected for public properties. All properties that have
annotations in doc comments are used in the form, unless they have an
ignore annotation.

Supported annations are @var to provide the type. When @var is array,
you need to specify the type of the elements in @element.

You can specify more validators for the field by adding @validator annotations.
Each annotation must be a Fully Qualified Class Name of a class can be be instantiated
using Wedeto\DI. A default constructor will suffice for this.

If you need more complex validators, you can also override the static listFieldValidators
method to return an array with field names as key and arrays of validators as value.

The class doc comment is used to assign validators to the form as a whole, using the
@validator annotation. The same rules for field validators apply. You can provide more
complex validators by overriding the static listFormValidators method.

@param string $formclass The class to build a form from
@return FormData The constructed form

@see Wedeto\Util\Validator
Create a form using reflection on a POPO .