geniv/nette-form

Form extension for Nette Framework

v1.1.8 2020-05-26 21:30 UTC

README

inspired by forms extension

html5 elements:

Installation

$ composer require geniv/nette-form

or

"geniv/nette-form": "^1.1"

require:

"php": ">=7.0",
"nette/application": ">=2.4",
"nette/di": ">=2.4",
"nette/forms": ">=2.4",
"nette/utils": ">=2.4",
"nette/php-generator": ">=2.4",
"geniv/nette-thumbnail": ">=1.0"

Include in application

neon configure extension:

extensions:
    - Form\Bridges\Nette\Extension

presenters:

$form->addDate($name, $label = null);
$form->addTime($name, $label = null);
$form->addDateTime($name, $label = null);
$form->addWeek($name, $label = null);
$form->addMonth($name, $label = null);
$form->addSearch($name, $label = null);
$form->addNumber($name, $label = null);

$form->addRange($name, $label = null)
    ->setStep($step)
    ->setMin($min)
    ->setMax($max)
    ->setValue($value);

$form->addColor($name, $label = null);

// use Thumbnail class
$form->addImg($name, $label = null)
    ->setPath(string $path, string $baseUrl = null)
    ->setImageSize(string $width = null, string $height = null, array $flags = [], int $quality = null)
    ->setValue($value);

// use Thumbnail class
$form->addUploadImage($name, $label = null, $multiple = false)
    ->setPath(string $path, string $baseUrl = null)
    ->setImageSize(string $width = null, string $height = null, array $flags = [], int $quality = null)
    ->setValue($value);

$form->addUploadFile($name, $label = null, $multiple = false)
    ->setPath(string $relativePath, string $absolutePath)
    ->setTarget(string $target)
    ->setValue($value);

$form->addHref($name, $label = null)
    ->setPrefix(string $prefix)
    ->setText(string $text)
    ->setHref(string $href)
    ->setTarget(string $target)
    ->setConfirm(string $text);

$form->addHrefLabel($name, $label = null)
    ->setText(string $text)
    ->setHref(string $href)
    ->setTarget(string $target)
    ->setConfirm(string $text);

$form->addLabel($name, $label = null, $element = 'div')
    ->setText(string $text);

$form->setGroup($name, $label = null, $element = 'div')
    ->begin(string $id)
    ->end();

usage for addUploadImage, addUploadFile, in default Nette renderer does not function:

{label cover_image /}
{input cover_image, class=>"form-control"}

{$form['cover_image']->getOption('content')}
{$form['cover_image']->getOption('path')}