Search by

blackcube / yii-form

Form fields for Yii framework, without any styling

Maintainers

Package info

github.com/blackcubeio/yii-form

pkg:composer/blackcube/yii-form

Transparency log

Statistics

Installs: 4

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

1.0.0 2026-09-04 09:55 UTC

This package is auto-updated.

Last update: 2026-09-04 09:58:30 UTC


README

Form fields for Yii 3, in native HTML, without any styling.

License Packagist Version

Version française : README.fr.md.

Installation

composer require blackcube/yii-form

Requirements

  • PHP 8.4
  • yiisoft/form, yiisoft/form-model, yiisoft/html, yiisoft/widget
  • blackcube/yii-bridge-model

What it is

The package builds the field: the block template, the containers, the attributes, the name, the id, the value, the label, the hint and the errors, everything yiisoft/form provides, assembled into a block ready to render.

It renders nothing but native HTML: an input, a textarea, a select with its optgroup, a checkbox, a radio button, a file field. No CSS class, no icon, nothing drawn.

blackcube/yii-bridge-model   the model
blackcube/yii-form           the fields
an interface project         inherits and styles them

Usage

use Blackcube\Form\Field\Input;

echo Input::create($model, 'email')->email()->render();

create() binds the field to a model property: name, id, value, label, hint, placeholder and errors derive from it. Without a model, the field is driven by hand:

echo Input::widget()->name('email')->email()->render();

The rendering produces the whole block: label, field, hint, error.

In a list, RadioList or CheckboxList, each item takes an id that yiisoft generates from the one of the field (Html::generateId()). An application that wants sequential ids, 1, 2, 3, sets IdGenerator::$useSeed = false at bootstrap.

The fields

field class
text, password, email, date, number, telephone, hidden Input
text area Textarea
dropdown list, its options and its groups Select
checkbox Checkbox
switch, a checkbox the interface draws Toggle
radio button Radio
group of radio buttons RadioList
group of checkboxes, sent as an array CheckboxList
file field Upload
field derived from a JSON schema Elastic
label Label
buttons Button, SubmitButton, ResetButton
joined buttons ButtonGroup

Styling the fields

Each styling hook is a protected method returning an empty array. A project sets its classes by inheriting:

class Input extends \Blackcube\Form\Field\Input
{
    protected function prepareClasses(): array
    {
        return ['block', 'w-full', 'rounded-md'];
    }
}

When the call sets its own classes, inputClass(), class(), they replace the ones of the component; the adding setters add to them.

The fields that go beyond native HTML, an icon inside the field, a search panel, a drop zone, are built the same way: inherit and render your own. That is what blackcube/yii-bleet does.

Tests

vendor/bin/codecept run

License

BSD-3-Clause. See LICENSE.md.

Copyright (c) 2026 Blackcube - Philippe Gaultier.

Author

Philippe Gaultier philippe@blackcube.io