Overview
This package is used to simplify the generation of HTML form inputs and the form tag itself. It can also create generic form elements by reverse engineering a database table. It’s meant to be very simple without extra features you might find in other packages. For example, you wont find validation here, or saving state. Just dead-simple form elements.
The package is fully tested, but if you find any missing coverage, just let me know.
Also of note, I don’t make any attempt to use a dependency injection container for loading the elements. In other words, you can’t inject your own Text object into the form. This may be added in the future.
Source is at https://bitbucket.org/vespula/vespula.form
Table of Contents
Installation
Installation via composer is easiest.
composer require vespula/form
Basic Usage
<?php
// The `post` method is the default.
$form = new \Vespula\Form\Form('post');
// Set the id and class attributes
$form->id('my-form')->class('myClass');
// Display the opening tag for the form
echo $form->begin();
// Alternatively, you can output the opening tag in one line.
// However, the begin() method must come last!
echo $form->id('my-form')->class('myClass')->begin();
echo $form->text()->id('my-input')->value('Joe User');
// specify the id and name attributes in one
echo $form->text()->idName('my-input')->value('Joe User');
// Close the form
echo $form->end();