tacoberu / nette-form-controls
Ext form controls for nette, DateInput, MultiUpload, and latte macros.
Installs: 2 153
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Language:JavaScript
Requires
- php: >=5.3.0
- nette/forms: ~3.0
- tacoberu/php-utils: @dev
Requires (Dev)
- php: >=5.3.0
- phpunit/phpunit: ~4.0
This package is auto-updated.
Last update: 2024-10-24 02:33:39 UTC
README
Ext form controls for Nette: DateInput, TimeInput, ColorInput, MultipleUploadControl, LabelField, SelectBoxRemoteControl and latte macros. With example javascript support.
Installation
composer require tacoberu/nette-form-controls
Usage
DateInput
$form = new Nette\Forms\Form; $form['date'] = new DateInputSingle('Date:', 'j. n. Y'); $form['date']->setStart(new Data\DateTime('2011-01-01')); $form['date']->setEnd(new Data\DateTime('2011-01-11')); $form['date']->setDefaultValue(new Data\DateTime('2003-12-02'));
TimeInput
$form = new Nette\Forms\Form; $form['time'] = new TimeInputSingle('Time:'); $form['time']->setDefaultValue(new Data\Time('20:12:02'));
ColorInput
$form = new Nette\Forms\Form; $form['color'] = new ColorInput('Color:'); $form['color']->setDefaultValue('#ababab');
MultipleUploadControl
$form = new Nette\Forms\Form; $form['attachments'] = new MultipleUploadControl('Color:'); $form['attachments']->setDefaultValue([ new Http\FileUploaded("uploaded/account/56695/mp16.jpg", "image/jpeg"), ]);
LabelField
$form = new Nette\Forms\Form; $form['label'] = new LabelField('Label:'); $form['label']->setDefaultValue('Lorem ipsum doler ist.');
SelectBoxRemoteControl
$form = new Nette\Forms\Form; // CallbackQueryModel is buildin implementation of generic QueryModel. $categorySelectQueryModel = new CallbackQueryModel(function($term, $page, $pageSize) use ($data) { $results = []; foreach ($data as $x) { if ($term && stripos($x->label, $term) === False) { continue; } $results[] = (object) [ 'id' => $x->id, 'label' => $x->label, ]; } $total = count($results); $offset = ($page - 1) * $pageSize; return (object) [ 'total' => $total, 'items' => array_slice($results, $offset, $pageSize), ]; }, function($id) use ($data) { foreach ($data as $x) { if ($x->id === $id) { return $x; } } }); $form['category'] = new SelectBoxRemoteControl($categorySelectQueryModel, 'Category:'); $form['tags'] = new MultiSelectBoxRemoteControl($this->getTagSelectQueryModel(), 'Tags:');
Form with initialized callback.
$form = new Taco\Nette\Application\UI\Form(null);
or
// callback will be called only at the beginning $form = new Taco\Nette\Application\UI\Form(function() { return [ 'id' => 42, 'title' => 'Lorem ipsum doler ist', ]; });