mskocik/forms

Additional form controls

Maintainers

Details

github.com/mskocik/forms

Source

Issues

Installs: 4

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 2

Forks: 0

Open Issues: 0

Language:JavaScript

v1.1 2024-05-10 17:11 UTC

This package is auto-updated.

Last update: 2024-11-10 18:30:26 UTC


README

Provide backend implementation of some svelte custom elements (svelecte and svelty-picker)

Install

composer require mskocik/forms

Register extension

extensions:
    ext.forms: Mskocik\Forms\Bridges\NetteDI\FormsExtension

If you are using nette/forms standalone, call control registration manually:

\Mskocik\Forms\Bridges\NetteDI\FormsExtension::init()

Extend nette form for IDE autocomplete

Extend Nette\Application\UI\Form (or Nette\Forms\Form if using standalone forms) and also Nette\Forms\Container with extended PHPDoc block:

<?php declare(strict_types=1);

use Nette\Application\UI\Form;
use Nette\Forms\Container;

/**
 * @method SveltyPicker 			addDatePicker(string $name, ?string $label = null, ?string $format = null)
 * @method SvelecteSelect			addSvelecteSelect(string $name, ?string $label = null, ?array $items = null)
 * @method SvelecteMultiSelect  	addSvelecteMultiSelect(string $name, ?string $label = null, ?array $items = null)
 */
class AppForm extends Form
{}

/**
 * @method SveltyPicker 			addDatePicker(string $name, ?string $label = null, ?string $format = null)
 * @method SvelecteSelect			addSvelecteSelect(string $name, ?string $label = null, ?array $items = null)
 * @method SvelecteMultiSelect  	addSvelecteMultiSelect(string $name, ?string $label = null, ?array $items = null)
 */
class AppFormContainer extends Container
{}

Use as needed!

$form = new Form();
$form->addSvelecteSelect('select', 'My Select', [/** item array */])
    ->setFetch($presenter->link('Api:fetch', ['id' => '[query]']))
    ->setRequired();
// ...