DEV Community

sebk69
sebk69

Posted on

Small Forms 1.7.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;
}
Enter fullscreen mode Exit fullscreen mode
$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)
);
Enter fullscreen mode Exit fullscreen mode

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

Heroku

Build apps, not infrastructure.

Dealing with servers, hardware, and infrastructure can take up your valuable time. Discover the benefits of Heroku, the PaaS of choice for developers since 2007.

Visit Site

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs