Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleš committed Sep 4, 2017
1 parent a70af86 commit 46b8d5f
Showing 1 changed file with 3 additions and 82 deletions.
85 changes: 3 additions & 82 deletions readme.md
Expand Up @@ -7,88 +7,9 @@ Form Renderer for [Nette Framework](https://nette.org) and [Bootstrap](http://ge
## Installation
The best way to install AlesWita/FormRenderer is using [Composer](http://getcomposer.org/):
```sh
# For PHP 7.1, Nette Framework 2.4/3.0 and Bootstrap
$ composer require aleswita/formrenderer:~1.3
$ composer require aleswita/formrenderer
```


## Usage
You can use renderer as classic renderer in form factory:
```php
$form = new Nette\Application\UI\Form;
$form->setRenderer(new AlesWita\FormRenderer\BootstrapV4Renderer);
```
..or you can use prepared factory:
```neon
services:
- AlesWita\FormRenderer\Factory(@Nette\Localization\ITranslator)
- App\Components\Forms\MyForm(@AlesWita\FormRenderer\Factory)
```
```php
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 your forms to [Bootstrap V4](https://getbootstrap.com/) design.

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

$form->addText('text2', 'Label:')
->addOption('right-addon', ['addon', 'text']);
```
- **Link Control** for forms, it's a form component, that can input link to your form as a button, look at the example:
```php
/**
* @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;
}
```
## Documentation
Documentation you can find in [Wiki](https://github.com/aleswita/FormRenderer/wiki).

0 comments on commit 46b8d5f

Please sign in to comment.