dravencms/base-form

DravenCMS Base Form

Maintainers

Package info

github.com/dravencms/base-form

Type:dravencms-package

pkg:composer/dravencms/base-form

Transparency log

Statistics

Installs: 202

Dependents: 3

Suggesters: 0

Stars: 0

Open Issues: 0

0.2.0 2026-07-01 18:10 UTC

This package is auto-updated.

Last update: 2026-08-24 22:38:36 UTC


README

Shared Nette form factory used by DravenCMS administration components. It creates the package-specific Form class and applies the translator and common rendering setup in one place.

Installation

composer require dravencms/base-form

The bundled configuration registers Dravencms\BaseForm\DI\BaseFormExtension. DravenCMS applications normally load it through the package metadata.

Usage

Inject BaseFormFactory into a control and create the form inside the component factory method:

use Dravencms\Components\BaseForm\BaseFormFactory;
use Dravencms\Components\BaseForm\Form;

final class ArticleForm
{
    public function __construct(
        private BaseFormFactory $baseFormFactory,
    ) {
    }

    protected function createComponentForm(): Form
    {
        $form = $this->baseFormFactory->create();
        $form->addText('title')->setRequired();
        $form->addSubmit('send');
        return $form;
    }
}

Set edit defaults on the local $form after its controls have been created. Do not access $this['form'] from a component constructor, because the Nette component tree is not ready there.

License

This package is licensed under the LGPL-3.0 license.