GithubHelp home page GithubHelp logo

fieldset's Introduction

Fuel Fieldset Package

Build Status Code Coverage Code Quality

This package will replace the default Fieldset class provided by the FuelPHP v1.x core by the FuelPHP v2.0 fieldset package.

Installing

Simply add "fuelphp/fieldset": "dev-master" to your composer.json and install. 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

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.

  • 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.

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 SimpleRender 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.

The render classes are all used in the same basic way:

<?php

use Fuel\Fieldset\Render;

$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 SimpleRender 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!

fieldset's People

Contributors

qweqq avatar sagikazarmark avatar wanwizard avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.