GithubHelp home page GithubHelp logo

nextras / forms Goto Github PK

View Code? Open in Web Editor NEW
49.0 21.0 29.0 159 KB

[DEPRECATED] Form controls for Nette Framework

Home Page: http://nextras.org/forms

License: MIT License

JavaScript 3.40% PHP 96.44% Shell 0.16%
php nextras nette-component forms

forms's People

Contributors

brosland avatar ciki avatar enumag avatar fabik avatar hrach avatar jantvrdik avatar jirinapravnik avatar jtojnar avatar majkl578 avatar pavelkouril avatar petrkalivoda avatar premekkoch avatar redwormik avatar trejjam avatar vlczech avatar woytam avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

forms's Issues

Nette 2.4: DatePicker false invalid result of validation

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="[{&quot;op&quot;:&quot;:filled&quot;,&quot;msg&quot;:&quot;Vyplňte, prosím, datum narození.&quot;},{&quot;op&quot;:&quot;:range&quot;,&quot;msg&quot;:&quot;Datum narození je příliš staré.&quot;,&quot;arg&quot;:[&quot;1867-05-16T09:33:15+01:00&quot;,null]},{&quot;op&quot;:&quot;:range&quot;,&quot;msg&quot;:&quot;Musíte být starší než 15 let.&quot;,&quot;arg&quot;:[null,&quot;2002-05-16T09:33:15+02:00&quot;]}]" 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é."

Undefined variable: _form

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í.

Latte syntax error

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...

Extension instead of bootstrap copy-pasting?

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.

DateTimePicker doesn't work with current Nette@dev

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

Partial rendering not working with BS3 macros

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."

compatibility with nette 2.2.*?

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>

Nevyplněné labely, vycentrování formuláře na střed

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 */

Not working autoloading.

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

But after running page exception occured.
nextras error

Undefined variable $_form, did you mean $form?

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?

Snippet support

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:

  • PullRequest to Nette with usage of interfaces instead of abstract class in UIRuntime
  • Some reflection hacks
  • Own snippet macro, with implementation from point 1

Tag new version

Could you pelase tag new version? I'd like to use extension from last summer.

Bootstrap error rendering

Please, modify form errors rendering to Bootstrap's .alert-danger divs. Now form errors are unstyled.

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.