nextras / forms Goto Github PK
View Code? Open in Web Editor NEW[DEPRECATED] Form controls for Nette Framework
Home Page: http://nextras.org/forms
License: MIT License
[DEPRECATED] Form controls for Nette Framework
Home Page: http://nextras.org/forms
License: MIT License
Zdravím,
vo verzii Nette 2.3.0 je potrebné presunúť volanie služby nette.latteFactory z loadConfiguration do metódy beforeCompile. Momentálne nevie nájsť službu.
Nette 2.4.1
PHP 7.1
Since upgrading to Nette 2.4 I face this issue:
Form factory:
use Nette\Application\UI\Form;
$form = new Form;
$form->addDatePicker('born', 'Datum narození:')
->setRequired('Vyplňte, prosím, datum narození.')
->addRule(Form::RANGE, 'Datum narození je příliš staré.',
[new DateTime('-150 years'), NULL])
->addRule(Form::RANGE, 'Musíte být starší než 15 let.',
[NULL, new DateTime('-15 years')])
->getControlPrototype()
->addClass('maxwidth-350 form-control');
Render result:
<input type="text" name="born" class="maxwidth-350 form-control date" id="frm-Career_ApplicantFormSection-careerForm-born" required="" data-nette-rules="[{"op":":filled","msg":"Vyplňte, prosím, datum narození."},{"op":":range","msg":"Datum narození je příliš staré.","arg":["1867-05-16T09:33:15+01:00",null]},{"op":":range","msg":"Musíte být starší než 15 let.","arg":[null,"2002-05-16T09:33:15+02:00"]}]" min="1867-05-16" max="2002-05-16">
I use this JS file for Nette forms validation:
https://github.com/nette/forms/blob/master/src/assets/netteForms.js
When I pick in DatePicker valid date e.g.: 16th May 2001, result is error: "Datum narození je příliš staré."
Při aktualizaci jednoho staršího projektu na Nette 2.4 jsem narazil s vlastními komponentami, založenými na Nextras\Forms\ComponentControl.
Zjednodušený kód:
class PublishingControl extends ComponentControl
{
public function __construct($caption = NULL)
{
parent::__construct($caption);
$this['draft'] = new Checkbox('Uložit draft, zatím nepublikovat');
$this['datePublish'] = new DatePicker('Datum zveřejnění');
}
}
šablona:
<div class="form-group">
<div class="checkbox">
{input draft}
</div>
</div>
<div id="{$toggleId}" class="form-group">
{label datePublish class => "control-label" /}
{input datePublish}
</div>
Nevím, zda tohle nějak nesouvisí s #49 . Pokud změním $_form na $form, změní se i hláška na "undefined variable: form".
"nextras/forms": "^2.0.1",
"nette/forms": "^2.4.6",
"latte/latte": "^2.4.6",
V configu:
extensions:
nextras.form: Nextras\Forms\Bridges\NetteDI\FormsExtension
latte:
macros:
- Nextras\Forms\Bridges\Latte\Macros\BS3InputMacros
Pokud vypnu BS3InputMacros, nic se nezmění. Pokud neaktivuju rozšíření nextras, dostanu end() expects parameter 1 to be array, null given
Verze 1.6.2 ve spojení s 2.3.x Nette fungovala podle očekávání.
Following lines BS3InputMacros#L21, BS3InputMacros#L31 are not compatible with parent declaration.
When typeahead hint is enabled, the duplicated input contains attributes of the original input (including data-nette-rules) so it breaks form validation. The followign code solves the problem:
$('.tt-hint').removeAttr('data-nette-rules');
IMHO, it could be mentioned in nextras.typeahead.init.js and save time others.
zapis makra:
{label list2:$key class => checkbox}
{input list2:$key}
{$label}
{/label}
nieje moc dobry, lebo ak mam:
{form myFrom}
{include #multiOptionListBlock, control => $form['controlName']}
{/form}
tu nemam premennu $_form cize nemozem zavolat {input list2:$key}
ale musim volat {input $control:$key}
to vsak hodi parse error syntax error, unexpected ':'
{define #multiOptionListBlock}
...
{label $control:$key}
{input $control:$key}
{$label}
{/label}
...
{/define}
viem ze to je error v latte, ale neviem ako tuto vec rozumne vyriesit...
There is no client-side validation when the picker is left empty.
tvoje makra https://github.com/nextras/forms/blob/master/Nextras/Forms/Latte/Macros.php niesu kompatibilne s http://api.nette.org/2.1/source-Latte.Macros.FormMacros.php.html#44
priklad:
{form myForm}
{label $form['control'] /}
{input $form['control']}
{/form}
ukazkovy kod funguje s nette macrom ale s tvojim uznie...
Is there a way to set DatePicker htmlType
& htmlFormat
variables?
https://github.com/nextras/forms/blob/master/src/Controls/DateTimePickerPrototype.php#L33 Shouldn't be there a setter for these?
Would you be interested in extension that would replace current bootstrap installation?
Something like this
It would result in simple one line registraion in config.neon
:
extensions:
- Nextrast\Forms\DI\Extension
If so, I would send PR.
Note: I think that also Register your Bootstrap 3 macros section could be managed by extension.
I have DateTimePicker with validation Rule (filled). In current Nette@dev rendering of date time picker this causes
Nette\MemberAccessException
Cannot read an undeclared property Nette\Forms\Rule::$type.
in ...\vendors\nextras\forms\Nextras\Forms\Controls\DatePicker.php:153
Seems that Rule::$type was removed few months ago in nette/nette@5aad1de
I have RadioList and I want render first label, then radio. So I have to use partial rendering:
{foreach $form['avatarId']->items as $key => $label}
{label avatarId:$key}{input avatarId:$key}
{/foreach}
And I get error: "Partial Nette\Forms\Controls\RadioList::getLabel() is deprecated; use getLabelPart() instead."
Do you plan in in near future?
When trying to test this extension, I get "Service templateCacheStorage is deprecated" error. I believe the problem is the compatibility with nette 2.2.0+ and on this line.
Same code works without problems on nette 2.1.4.
simplest example code
class ExampleControl extends ComponentControl {
}
template:
<p>example</p>
Pokud si nevplním label, tak se zobrazí nevyplněný label (col-md-3) a prvky (col-md-9) se zobrazí na druhé polovině obrazovky.
Je nějaká možnost vypnout ten label, aby byl na centru obrazovky, aniž bych editoval toto?
$this->wrappers['control']['container'] = 'div class=col-sm-12'; /* col-md-9 */
$this->wrappers['label']['container'] = 'div class="control-label"'; /* col-md-3 */
I added this addon to nette by composer using command composer require nextras/forms and version @dev.
Then I added row to config.neon:
extensions:
nextrasForms: Nextras\Forms\DI\FormsExtension
Když přepíšu $_form na $form (na řádku 83 v BaseInputMacro z verze 2.0.1, tzn. " : '$_input = $_form[%0.word];' " => " : '$_input = $form[%0.word];' " ), vše je v pořádku. Stejně tak je vše v pořádku, když vypnu nextras v configu. Stejně tak když v Datagrid.latte (z twigrid) do {input filters-criteria-$column} přidám $form, tedy {input $form["filters-criteria-$column"]}. Máte nápad, v které komponentě by mohl být problém a co s tím?
I have implemented ComponentControl
and tried to use snippets, but there are two problems.
One is that invalidateControl method (in TemplateControlTrait) should be deprecated and replaced with redrawControl (outdated implementation). Probably ComponentControl would implement \Nette\Application\UI\IRenderable
.
Second problem is IMHO larger, because of typehint in UIRuntime, which needs UI\Control.
I'm not sure if you have gone around this (code looks like that) or is it new in Nette.
Here are few thoughts to "fix" this:
Could you pelase tag new version? I'd like to use extension from last summer.
Please, modify form errors rendering to Bootstrap's .alert-danger
divs. Now form errors are unstyled.
Thanks!
I needed to use datetimepicker with seconds as well, but the support is completely missing. :(
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.