Search by

drago-ex / form

accgit

Helper classes for Nette forms with extended inputs and shortcuts.

Package info

github.com/drago-ex/form

pkg:composer/drago-ex/form

Statistics

Installs: 1 774

Dependents: 9

Suggesters: 0

Stars: 0

Open Issues: 0

v4.0.0 2026-11-14 09:50 UTC

README

Nette forms with typed inputs and fluent attributes (autocomplete, placeholder, read-only), and ready-made email and password fields.

License: MIT PHP version Tests Coding Style

Requirements

  • PHP >= 8.3, < 9
  • Nette Framework
  • Composer

Installation

composer require drago-ex/form

Forms

$form = new Drago\Form\Forms();

$form->addTextInput('username', 'Username')
     ->setAutocomplete(Drago\Form\Autocomplete::Username)
     ->setPlaceholder('Enter your username');

$form->addIntegerInput('age', 'Age')
     ->setMin(0)
     ->setMax(120);

Inputs

Drago\Form\Forms adds addTextInput(), addEmailInput(), addPasswordInput(), addIntegerInput(), addSlugInput() and addTextAreaInput(); their inputs have the fluent setters setAutocomplete() (values of the Autocomplete enum), setPlaceholder() and setReadOnly(). Standard Nette controls keep working.

addSlugInput() is a text input with the Forms::SlugPattern rule (lowercase letters, numbers, single hyphens) and at most 255 characters, the length of the slug columns; the constant also fits route masks.

IntegerInput is validated as an integer on the server, like Nette's addInteger(): an empty value is null and a valid value is converted to int. setMin() and setMax() add server-side rules and render the min and max attributes.

setReadOnly() only renders the HTML readonly attribute; the browser still submits the value and a user can change it. For values that must not be changed, use setOmitted() and keep the value on the server, or setDisabled().

ExtraForms

ExtraForms extends Forms with commonly used preconfigured fields:

  • addPasswordField() - password input named password.
  • addPasswordConfirmationField() - password confirmation named verify, validated against password.
  • addEmailField() - email input named email with autocomplete and email validation.