Skip to content
🔁 Form multiplier & replicator for Nette Framework
Branch: master
Clone or download
Latest commit 84f6e45 Jul 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src addSetup() replace with getResultDefinition()->addSetup() May 16, 2019
tests add onRemove event Feb 27, 2019
.gitignore contributte Feb 21, 2019
.travis.yml min. php 7.2 Feb 22, 2019
README.md contributte Feb 21, 2019
codeception.yml contributte Feb 21, 2019
composer.json Add master alias Jul 9, 2019
ruleset.xml contributte Feb 21, 2019

README.md

Multiplier, replication for Nette\Forms

Build Status

Installation

composer require contributte/forms-multiplier
extensions:
    - Contributte\FormMultiplier\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')
	->addClass('btn btn-primary');
$multiplier->addRemoveButton('Remove')
	->addClass('btn btn-danger');

Adding multiple containers

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

Macros

{form multiplier}
	<div n:multiplier="multiplier">
		<input n:name="text">
		{btnRemove 'class' => 'myClass'}
	</div>
	{btnCreate multiplier class => myClass}
	{btnCreate $form[multiplier]:5}
{/form}
You can’t perform that action at this time.