Statistics
16
2
0
6d
Badges
Tags
forms
Dependencies

Form Renderer

Form Renderer for Nette Framework and Bootstrap.

Build Status Coverage Status

Installation

The best way to install AlesWita/FormRenderer is using Composer:

# For PHP 7.1, Nette Framework 2.4/3.0 and Bootstrap
$ composer require aleswita/formrenderer:~1.0

Usage

You can use renderer as classic renderer in form factory:

$form = new Nette\Application\UI\Form;
$form->setRenderer(new AlesWita\FormRenderer\BootstrapV4Renderer);

..or you can use prepared factory:

services:
	- AlesWita\FormRenderer\Factory(@Nette\Localization\ITranslator)
	- App\Components\Forms\MyForm(@AlesWita\FormRenderer\Factory)
final class MyForm extends Nette\Application\UI\Control
{
	/** @var AlesWita\FormRenderer\Factory */
	private $factory;


	/**
	 * @param AlesWita\FormRenderer\Factory
	 */
	public function __construct(AlesWita\FormRenderer\Factory $factory)
	{
		$this->factory = $factory;
	}


	/**
	 * @return Nette\Application\UI\Form
	 */
	public function create(): Nette\Application\UI\Form
	{
		$form = $this->factory->create();

		...

		return $form;
	}
}

Features

BootstrapV4Renderer convert you forms to Bootstrap V4 design.

Renderer support:

  • form errors
  • groups
  • groups description
  • input errors
  • input description
  • input addons (left, right, both or multiple addons)
$form->addText('text1', 'Label:')
	->addOption('left-addon', 'addon text');

$form->addText('text2', 'Label:')
	->addOption('right-addon', ['addon', 'text']);
  • Link Control for forms

Link control it's a form component, that can input link to your form as a button, look at the example:

/**
 * @return Nette\Application\UI\Form
 */
public function create(): Nette\Application\UI\Form
{
	$form = $this->factory->create();

	...

	$form->addComponent(new AlesWita\FormRenderer\Controls\Link('Cancel'), 'cancel');

	$form['cancel']->getControlPrototype()
		->addClass('ajax')
		->setHref($this->link('cancel!'));

	return $form;
}
  • 1.1 Version 1.1

    • compatibility with Bootstrap v4.0.0-beta
    • make compatibility with small, medium and large devices
  • 1.0 Version 1.0

    • For Nette Framework: ~2.4.0 || ~3.0.0
    • For PHP: ~7.1

Is this addon outdated? Did you find an issue? Please report it.

Componette Componette admin@componette.com