Skip to content

luksh123/forms-multiplier

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Multiplier, replication for Nette\Forms

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');

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}

About

Multiplier, replicator for nette forms

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • PHP 99.8%
  • HTML 0.2%