2017 © Pedro Peláez
 

library fieldset

Form generation and building

image

fuelphp/fieldset

Form generation and building

  • Monday, April 6, 2015
  • by WanWizard
  • Repository
  • 8 Watchers
  • 8 Stars
  • 1,899 Installations
  • PHP
  • 6 Dependents
  • 1 Suggesters
  • 4 Forks
  • 8 Open issues
  • 1 Versions
  • 1 % Grown

The README.md

Fuel Fieldset

Build Status Code Coverage Quality Score HHVM Status, (*1)

Form generation and building., (*2)

This package will replace the default Fieldset class provided by the FuelPHP v1.x core by the FuelPHP v2.0 fieldset package., (*3)

Install

Via Composer, (*4)

``` bash $ composer require fuelphp/fieldset, (*5)


Once the package reaches a suitable milestone a tagged release will be created. ## Getting started Forms are created by first creating a container object, a `Form` or a `Fieldset`. You can then add `Inputs` to these containers. ```php <?php use Fuel\Fieldset\Form; use Fuel\Fieldset\Input; $form = new Form; $form[] = new Input\Text('name'); $form[] = new Input\Submit('submit', [], 'GO!'); //This will repopulate the form with any submitted data $form->repopulate(); //This will repopulate the form with the given data, the flag indicates wether to call `repopulate()` after or not $form->populate($myData, true);

InputElement types

The current InputElement classes exist., (*6)

  • Button
  • Checkbox
  • CheckboxGroup
  • Email
  • File
  • Hidden
  • Optgroup
  • Option
  • Password
  • Radio
  • RadioGroup
  • Reset
  • Select
  • Submit
  • Text
  • Textarea

Grouped check boxes and radio buttons now have their own logic for repopulation and naming when used in groups, hence the ChecboxGroup and RadioGroup classes. Select elements are comprised of Options and Optgroups. For more info on check box/radio groups and selects please see here., (*7)

Showing the form

Unlike v1 fieldsets a totally separate class is used to create the html for the form. Whilst each InputElement knows how to display itself in the most basic form the use of a Renderer allows for more complex behaviour to be achieved. This can include things such as generating the form in a table or as a list. By default BasicRender will render the form in a table, much the same as the v1 fieldsets did. In the future other basic renderers might be added to the package to support things like list based forms out of the box. Pull/merge requests are always welcome., (*8)

The render classes are all used in the same basic way:, (*9)

<?php

use Fuel\Fieldset\Render\BasicRender;

$engine = new BasicRender();

$formHtml = $engine->render($form);

It is easily possible to create your own renderer if the default one does not suit your needs. For an example take a look at the BasicRender code and additionally here. If you do make your own renderer for a UI kit or css framework then please consider submitting a pull request!, (*10)

Included Renderers

Fieldset comes with a couple of basic renderes, a generic one that does not add any formatting or css and a Bootstrap3 based renderer that will build forms that are compatible with the Bootstrap CSS framework., (*11)

3rd party renderers

The Versions

06/04 2015

dev-master

9999999-dev https://github.com/fuelphp/fieldset

Form generation and building

  Sources   Download

MIT

The Requires

 

The Development Requires

by FuelPHP Development Team

form fieldset form builder