Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/tacoberu/nette-form-controls
Ext form controls for nette, DateInput, MultiUpload, and latte macros.
https://github.com/tacoberu/nette-form-controls
Last synced: 15 days ago
JSON representation
Ext form controls for nette, DateInput, MultiUpload, and latte macros.
- Host: GitHub
- URL: https://github.com/tacoberu/nette-form-controls
- Owner: tacoberu
- License: mit
- Created: 2013-12-07T23:11:47.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T03:52:29.000Z (11 months ago)
- Last Synced: 2024-04-25T15:22:31.183Z (9 months ago)
- Language: JavaScript
- Size: 265 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
nette-form-controls
===================[![Build Status](https://travis-ci.org/tacoberu/nette-form-controls.svg?branch=master)](https://travis-ci.org/tacoberu/nette-form-controls)
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
```php
$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
```php
$form = new Nette\Forms\Form;$form['time'] = new TimeInputSingle('Time:');
$form['time']->setDefaultValue(new Data\Time('20:12:02'));```
### ColorInput
```php
$form = new Nette\Forms\Form;$form['color'] = new ColorInput('Color:');
$form['color']->setDefaultValue('#ababab');```
### MultipleUploadControl
```php
$form = new Nette\Forms\Form;$form['attachments'] = new MultipleUploadControl('Color:');
$form['attachments']->setDefaultValue([
new Http\FileUploaded("uploaded/account/56695/mp16.jpg", "image/jpeg"),
]);```
### LabelField
```php
$form = new Nette\Forms\Form;$form['label'] = new LabelField('Label:');
$form['label']->setDefaultValue('Lorem ipsum doler ist.');```
### SelectBoxRemoteControl
```php
$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.
```php
$form = new Taco\Nette\Application\UI\Form(null);
```
or```php
// callback will be called only at the beginning
$form = new Taco\Nette\Application\UI\Form(function() {
return [
'id' => 42,
'title' => 'Lorem ipsum doler ist',
];
});
```