geniv/nette-html-select

Html select component for Nette Framework

v1.0.11 2019-07-22 20:28 UTC

This package is auto-updated.

Last update: 2020-09-17 11:06:06 UTC


README

Installation

$ composer require geniv/nette-html-select

or

"geniv/nette-html-select": ">=1.0"

require:

"php": ">=7.0",
"nette/application": ">=2.4",
"nette/utils": ">=2.4",
"geniv/nette-general-form": ">=1.0"

Include in application

neon configure services:

services:
    - HtmlSelect

presenter usage:

protected function createComponentHtmlSelect(HtmlSelect $htmlSelect): HtmlSelect
{
    $htmlSelect->setTemplatePath(__DIR__ . '/templates/htmlSelect.latte');

    // add all in one - strict internal check route for method: setRoute()
    $htmlSelect->setRoute('SwitchFkId!');
    $htmlSelect->setPrompt('-- žádný výběr --');
    $htmlSelect->clearItems();
    $htmlSelect->addItem('name', 'param');
    $htmlSelect->setItems([1 => 'a', 2 => 'b']);
    $htmlSelect->setItems([1 => 'a', 2 => 'b'], false);

    $htmlSelect->addVariableTemplate([1 => 'a']);
    
    $htmlSelect->setActiveValue('aaaxx');

    // add step by step - nothing internal check
    $htmlSelect->setParameter('order', 'asc');
    $htmlSelect->addLink('Abecedně A - Z', 'Sort!', ['order' => 'asc']);
    $htmlSelect->addLink('Abecedně Z - A', 'Sort!', ['order' => 'desc']);
    return $htmlSelect;
}

latte usage:

{control htmlSelect}