Skip to content
This repository has been archived by the owner on Mar 29, 2019. It is now read-only.

Latest commit

 

History

History
139 lines (82 loc) · 2.99 KB

index.md

File metadata and controls

139 lines (82 loc) · 2.99 KB

Kdyby/BootstrapRenderer Build Status

Forms Renderer for Nette Framework, that allows partial rendering and uses Twitter Bootstrap markup and classes.

Requirements

Kdyby/BootstrapRenderer requires PHP 5.3.2 or higher.

Installation

  • Get composer
  • Install package kdyby/bootstrap-form-renderer

Macros

If you wanna use the special macros, you have to register them into Latte Engine

Kdyby\BootstrapFormRenderer\Latte\FormMacros::install($engine->compiler);

Or simply register the extension in app/bootstrap.php to allow them globally

Kdyby\BootstrapFormRenderer\DI\RendererExtension::register($configurator);

Usage

First you have to register the renderer to form.

use Kdyby\Extension\Forms\BootstrapRenderer\BootstrapRenderer;
$form->setRenderer(new BootstrapRenderer);

For performance optimizations, you can provider your own template instance.

// $this instanceof Nette\Application\UI\Presenter
$form->setRenderer(new BootstrapRenderer($this->createTemplate()));

All the usage cases expects you to have the form component in variable named $form

Basic rendering

Entire form

{control formName} or {form formName /}

Beginning of the form

{$form->render('begin')} or {form $form} or {form formName}

Errors

Renders only errors, that have not associated form element.

{$form->render('errors')} or {form errors}

Body

Renders all controls and groups, that are not yet rendered.

{$form->render('body')} or {form body}

Controls

Renders all controls, that are not yet rendered. Doesn't render buttons.

{$form->render('controls')} or {form controls}

Buttons

Renders all buttons, that are not yet rendered.

{$form->render('buttons')} or {form buttons}

End

Renders all hidden inputs, and then the closing tag of form.

{$form->render('end')} or {/form}

Rendering of form components

Control

Renders the container div around the control, its label and input.

{$form->render($form['control-name'])} or {pair control-name}

Container

Renders all the inputs in container, that are not yet rendered.

{$form->render($form['container-name'])} or {container container-name}

Group

Renders fieldset, legend and all the controls in group, that are not yet rendered.

{$form->render($form->getGroup('Group name'))} or {group "Group name"}

Kdyby Framework: homepage http://www.kdyby.org and repository http://github.com/kdyby/framework. Sandbox, pre-packaged and configured project: http://github.com/kdyby/sandbox