webchemistry/forms-multiplier

There is no license information available for the latest version (2.0) of this package.

Multiplier for nette forms

2.0 2016-07-08 11:46 UTC

README

Build Status

Installation

composer require webchemistry/forms-multiplier
extensions:
    - WebChemistry\Forms\Controls\DI\MultiplierExtension

Usage

$form = new Nette\Forms\Form;
$copies = 1;
$maxCopies = 10;

$multiplier = $form->addMultiplier('multiplier', function (Nette\Forms\Container $container, Nette\Forms\Form $form) {
    $container->addText('text', 'Text')
                ->setDefaultValue('My value');
}, $copies, $maxCopies);

$multiplier->addCreateButton('Add');
$multiplier->addRemoveButton('Remove');

More create buttons

$multiplier->addCreateButton('Add'); // add one container
$multiplier->addCreateButton('Add 5', 5); // add five containers