2017 © Pedro Peláez
 

library form-selectize

Form extension for Nette framework

image

olicek/form-selectize

Form extension for Nette framework

  • Sunday, March 26, 2017
  • by Oli
  • Repository
  • 3 Watchers
  • 10 Stars
  • 1,598 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 9 Forks
  • 2 Open issues
  • 3 Versions
  • 5 % Grown

The README.md

form-selectize

Latest stable Packagist, (*1)

Form extension for Nette framework, (*2)

More documentations

  • [javascript settings] (https://github.com/Olicek/form-selectize/blob/master/docs/en/javascript.md)
  • [ajax] (https://github.com/Olicek/form-selectize/blob/master/docs/en/ajax.md)

Requirements

  • Nette 2.2+
  • jQuery 1.8+
  • [Selectize] (https://github.com/brianreavis/selectize.js)

Installation

The best way to install olicek/form-selectize is using Composer:, (*3)

$ composer require olicek/form-selectize

After installation server site, you have to install client site. The best way is use bower., (*4)

Link selectize.js from client-side and original selectize.js and call somewhere function selectize()., (*5)

| NOTE: If you need use previous javascript, it is available in selectize-old.js, (*6)

Last step is enable the extension using your neon config, (*7)

extensions:
    selectize: App\Form\Control\SelectizeExtension

Default configuration

selectize:
    mode: full # second mode is `select` for selection just 1 option
    create: on
    maxItems: null
    delimiter: #/
    plugins:
        - remove_button
    valueField: id
    labelField: name
    searchField: name

Data in array for full mode

array (2)
    0 => array (2)
        id => 1
        name => "First item"
    1 => array (2)
        id => 2
        name => "Second item"

id is set as valueField and name as labelField and searchField in config.neon. You can use whatever, have to just set in config.neon or in addSelectize method. For example:, (*8)

valueField: slug

Data in array for select mode

Data for select mode are same as for SelectBox:, (*9)

array (2)
    1 => "First item",
    2 => "Second item"

Using

Default settings from config.neon

$form->addSelectize('tags', 'štítky', $arrayData);

custome settings in method first way (array)

$form->addSelectize('tags', 'štítky', $arrayData, ['create' => false, 'maxItems' => 3]);

custome settings in method first way (method)

$form->addSelectize('tags', 'štítky', $arrayData)->setValueField('slug')->delimiter('_');

Output is:

Select mode

dump($form->values->tags); // return "1"

Full mode

In full mode it will return array with valueField values. If you create some new tag, it will in sub array with plain text., (*10)

array (3)
    0 => "1"
    1 => "2"
    new => array (1)
        0 => "Third item"

The Versions

26/03 2017
29/09 2015

v0.9

0.9.0.0 https://github.com/Olicek/form-selectize

Form extension for Nette framework

  Sources   Download

GPL-3.0

The Requires