Home > Backend Development > PHP Tutorial > Small Forms .0

Small Forms .0

Linda Hamilton
Release: 2024-12-18 00:08:09
Original
719 people have browsed it

Small Forms .0

New Release of small/forms: 1.7.0

  • Now supports form creation: the adapter annotation can now process classes with a recursive definition.
  • New method: fillFromObject
  • Added the objectToArray method to serialize an object into a PHP array.
class InputBasic
{
    #[StringType]
    private string          $string;
    #[BooleanType]
    private bool            $boolean;
    #[IntType]
    private int             $int;
    #[FloatType]
    private float           $float;
    #[ArrayType(new IntType())]
    private array           $array;
    #[SubFormType(InputBasic::class)]
    private InputBasic|null $subObject = null;
}
Copy after login
$dto = new \Small\Forms\Test\Fixture\InputObject\InputBasic();
$dto->setArray([2, 3]);
$dto->setSubObject(
    (new \Small\Forms\Test\Fixture\InputObject\InputBasic())
    ->setString('string2')
    ->setArray([6, 7])
);

$form = \Small\Forms\Form\FormBuilder::createFromAdapter(
    new \Small\Forms\Adapter\AnnotationAdapter($dto)
);
Copy after login

git repo : https://git.small-project.dev/lib/small-forms
packagist : https://packagist.org/packages/small/forms

The above is the detailed content of Small Forms .0. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template