2017 © Pedro Peláez
 

library nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

image

vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  • Thursday, April 4, 2013
  • by vojtechdobes
  • Repository
  • 8 Watchers
  • 25 Stars
  • 1,130 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 6 Versions
  • 0 % Grown

The README.md

For Nette Framework

Alternative RadioList & CheckboxList for Nette Framework, (*1)

License

New BSD, (*2)

Dependencies

Nette 2.0.0, (*3)

Installation

  1. Get the source code from Github or via Composer (vojtech-dobes/nette-forms-inputlist).
  2. Register VojtechDobes\NetteForms\InputListExtension as extension for $configurator.
$configurator->onCompile[] = function ($configurator, $compiler) {
    $compiler->addExtension('inputlist', new VojtechDobes\NetteForms\InputListExtension);
};

Usage

RadioList

$form->addMultiRadio('sex', 'Sex:', array(
    'male' => 'Male',
    'female' => 'Female',
));

Method's name was chosen to not interfere with native addRadiolist., (*4)

CheckboxList

$checkboxlist = $form->addMultiCheckbox('topics', 'I like:', array(
    'l' => 'lifestyle',
    'm' => 'military',
    'c' => 'computers',
    'f' => 'flowers',
));
Defaults
$checkboxlist->setDefaultValue(array('l', 'm')); // lifestyle, military
Returned values
$checkboxlist->getValue() === array(0 => 'l', 1 => 'm')

Rendering

Automatic

Both RadioList and CheckboxList provide standard mechanism like getControlPrototype etc. You can also force omitting of last separator:, (*5)

$radiolist->omitLastSeparator();

Manual

There is special new macro for Latte templates: {inputlist}. It behaves exactly like {foreach}, but it's specifically design to work with *List form elements., (*6)

{form formName}
    {inputlist sex as $key => $label}
        {input} {label /} {sep}<br>{/sep}
    {/inputlist}
{/form}

Macros {input} and {label} behave the same way as always, but when used without element identificator, they will render proper elements for iteration specific item. If you use it with identificator, it will render appropriate element from form., (*7)

{form formName}
    {inputlist sex as $key => $label}
        {input} {label /}<br>
        {input send} {* standard button, no problem *}
    {/inputlist}
{/form}

You can add HTML attributes to them as usually., (*8)

{form formName}
    {inputlist sex as $key => $label}
        {input class => 'input-radio'} {label}{$label}{/label}<br>
    {/inputlist}
{/form}

Attribute version of {inputlist} is also possible:, (*9)

{form formName}
    <ul n:inner-inputlist="sex as $key => $label">
        <li>{input} {label /}</li>
    </ul>
{/form}

Validation

Here supported rules are listed:, (*10)

CheckboxList

Form::FILLED At least one box must be checked.
Form::LENGTH Exact amount of boxes that must be checked.
Form::MIN_LENGTH Minimum amount of boxes that must be checked.
Form::MAX_LENGTH Maximum amount of boxes that must be checked.
Form::RANGE Minimum and maximum amount of boxes that must be checked.
Form::REGEXP Checks if selected checkbox values match regular expression.

RadioList

Form::FILLED One button must be selected.
Form::REGEXP Checks if selected radio value matches regular expression.

All rules are also supported on client-side., (*11)

The Versions

04/04 2013

dev-master

9999999-dev http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist

04/04 2013

1.0.4

1.0.4.0 http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist

04/03 2013

1.0.3

1.0.3.0 http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist

27/01 2013

1.0.2

1.0.2.0 http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist

13/01 2013

1.0.1

1.0.1.0 http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist

10/12 2012

1.0.0

1.0.0.0 http://github.com/vojtech-dobes/nette-forms-inputlist

Alternative RadioList & CheckboxList for Nette Framework

  Sources   Download

New BSD

The Requires

 

forms nette radiolist checkboxlist