2017 © Pedro Peláez
 

library formidable-bootstrap

Twitter Bootstrap 3 integration for Formidable

image

soliantconsulting/formidable-bootstrap

Twitter Bootstrap 3 integration for Formidable

  • Tuesday, October 4, 2016
  • by jeremiahsmall
  • Repository
  • 3 Watchers
  • 0 Stars
  • 20 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

Formidable Bootstrap

This package supplies a selection of view helpers to ease rendering of forms with Formidable and Twitter Bootstrap 3. By default, it ships with a factory to use the helpers in Plates, but the view helpers can also be used in other template engines which support callables., (*1)

The supplied view helpers have a very opinionated HTML output. If you need a different kind of output, this library is not for you, and you should write your own helpers., (*2)

Installation

Install via composer:, (*3)

$ composer require soliantconsulting/formidable-bootstrap

Usage

Here is a simple example for using the different view helpers in your templates:, (*4)



formErrors($form->getGlobalErrors()); ?> inputText('Name', $form->getField('name')); ?> inputText('Color', $form->getField('color'), 'color'); ?> inputPassword('Password', $form->getField('password')); ?> textarea('Notes', $form->getField('notes')); ?> select('Role', $form->getField('role'), ['user' => 'User', 'admin' => 'Admin']); ?> select('Groups', $form->getField('role'), ['alpha' => 'Alpha', 'beta' => 'Beta'], true); ?> select('Country', $form->getField('country'), [ 'Europe' => [ 'de' => 'Germany', 'fr' => 'France', ], 'America' => [ 'ca' => 'Canada', 'us' => 'United States', ], ]); ?> checkbox('Active', $form->getField('active')); ?>

As you can see, some view helpers take additional optional parameters. The inputText() helper takes an type as third parameter, By default, it will render a generic text input, but you can change it to any other input type., (*5)

The select() view helper takes a boolean as last argument, which indicates whether it should be multiple or not. The mandatory options array can either be a simple string to string map, or contain nested arrays like in the country example to generate option groups, which can be nested indefinitely., (*6)

If you need to separate your form into fieldsets, you can do that manually. There is no need for any additional helpers there. When you have a child object in your form which can get errors assigned, so that they are not associated with a specific field, you can pull the errors from a pseudo field and pass them to the formErrors() view helper:, (*7)



Address formErrors($form->getField('address')->getErrors()); ?> inputText('Street', $form->getField('address.street')); ?> inputText('City', $form->getField('address.city')); ?> inputText('Zipcode', $form->getField('address.zipcode')); ?>

Custom error messages

By default, the view helpers use error messages supplied by Formidable itself. If you want to use different messages or have your own constraints with custom error messages, you add additional messages via configuration:, (*8)

return [
    soliant_formidable_bootstrap => [
        'messages' => [
            'error.custom' => 'Some custom error',
        ],
    ],
];

The messages follow the same pattern used by Formidable's ErrorFormatter., (*9)

The Versions

04/10 2016

dev-master

9999999-dev

Twitter Bootstrap 3 integration for Formidable

  Sources   Download

MIT

The Requires

 

by Ben Scholzen

04/10 2016

0.1.2

0.1.2.0

Twitter Bootstrap 3 integration for Formidable

  Sources   Download

MIT

The Requires

 

by Ben Scholzen

13/09 2016

0.1.1

0.1.1.0

Twitter Bootstrap 3 integration for Formidable

  Sources   Download

MIT

The Requires

 

by Ben Scholzen

13/09 2016

0.1.0

0.1.0.0

Twitter Bootstrap 3 integration for Formidable

  Sources   Download

MIT

The Requires

 

by Ben Scholzen