Form automation for Granada ORM models

Installs: 54

Dependents: 0

Suggesters: 1

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/granadaorm/form

1.4.6 2024-01-29 03:35 UTC

This package is auto-updated.

Last update: 2025-09-29 02:43:26 UTC


README

Automated forms for models built with GranadaORM/Builder

Installation

Simply install using composer:

composer require granadaorm/form

Usage

First, load up a record from the database using the model built from the Builder:

$affiliate = \MyCustomApp\Affiliate::model()->find_one();

Then create a form, specifying the framework of the page, e.g. Bootstrap (bs3/bs4) or Bulma:

$form = $affiliate->getForm(\Granada\Form\Bulma::class);

And render it to the page:

echo $form->beginForm();
echo $form->renderFields();
echo $form->build()
    ->setType('submit')
    ->setValue('Save')
    ->render();
echo $form->endForm();

Rendering Partial Forms

To only show select fields or set the order manually, you can specify the fields individually:

echo $form->beginForm();
echo $form->renderField('name');
echo $form->renderField('phone');
echo $form->build()
    ->setType('submit')
    ->setValue('Save')
    ->render();
echo $form->endForm();