2017 © Pedro Peláez
 

library form

image

laasti/form

  • Wednesday, October 28, 2015
  • by nebulousGirl
  • Repository
  • 1 Watchers
  • 0 Stars
  • 221 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 2 Open issues
  • 7 Versions
  • 4 % Grown

The README.md

Laasti/form

Installation

composer require laasti/form

Usage

Forms have groups containing multiple fields., (*1)


$form = new Laasti\Form\Form($data, $errors, $rules); $form->setMethod('post'); //Defaults to post $form->setAction('url'); $form->setAttributes([/*html attributes*/]); $form->addField('text', 'field', 'Label', [/*choices*/], 'group', [/*input attributes*/], [/*row attributes*/]); $form->removeField('field'); $form->removeGroup('group'); $form->setGroup('field', 'group'); $form->setLabel('field', 'Label'); $form->setType('field', 'type'); $form->setAttributes('field', [/*attributes*/]); $form->setContainerAttributes('field', [/*attributes*/]); $form->setData([]); $form->setErrors([]); $form->setRules([]); $form->setGroupsLayout([ 'top', 'main' => ['column1', 'column2'], 'secondary' => ['side', 'wide'], 'multi-level' => [ 'subsection' => ['sub-column1', 'sub-column2'], 'subsection2' ] ]); $form->defineGroup('group', 'Title', [/*attributes*/]);

Then in your view:, (*2)


$form->getAction(); //Get form action attribute $form->getMethod(); //Get form method $form->getFormAttributes(); //Get form attributes $form->getAllFields(); //All fields without groups $form->getFields(); //Just fields without groups $group = array_shift($form->getGroups()); //Array of first level groups $group->getLabel(); $group->getAttributes(); $group->getGroups(); //Array of subgroups $field = array_shift($group->getFields()); //Array of fields in group $field->getLabel(); $field->getName(); $field->getGroup(); $field->getChoices(); $field->getAttributes(); $field->getContainerAttributes(); //OR you can use magic properties instead of lengthy getters in views $field->choices; $field->containerAttributes; //There are some magic properties as well $field->isRequired;//Checks if required exists in $field->attributes $field->is{Name};//If you want to identify a field by its name $field->is{Type};//If you want to check a field's type

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b my-new-feature
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin my-new-feature
  5. Submit a pull request :D

History

See CHANGELOG.md for more information., (*3)

Credits

Author: Sonia Marquette (@nebulousGirl), (*4)

License

Released under the MIT License. See LICENSE.txt file., (*5)

The Versions

28/10 2015

dev-master

9999999-dev

  Sources   Download

MIT

28/10 2015

v0.2.2

0.2.2.0

  Sources   Download

MIT

27/09 2015

v0.2.1

0.2.1.0

  Sources   Download

MIT

21/09 2015

v0.2

0.2.0.0

  Sources   Download

MIT

10/09 2015

v0.1.1

0.1.1.0

  Sources   Download

MIT

09/09 2015

v0.1

0.1.0.0

  Sources   Download

MIT

09/09 2015

dev-input-generator

dev-input-generator

  Sources   Download

MIT