jak do formulare ajaxove poslat error

karambastop
Člen | 5
+
0
-

Zdravim,
resim, jak ajaxove do formulare poslat error. Rad bych to delal pomoci snippetu.

Sablona zjednodusene vypada takto:

{snippetArea regform}
	{form registerForm}
		<p class="error" n:foreach="$form->errors as $error">{$error}</p>
		{input ...}
		{input ...}
 		{snippet autoCompleteSelect}{input autoCompleteSchool}{/snippet}
	{/form}
{/snippetArea}

Obalit p error snippetem nebude fungovat, protoze v nem pri ajaxovem pozadavku chybi promena $form (vim o moznostech, jak do toho snippetu dostat $form, ale neni to ciste reseni).
Pouzit snippet misto snippetArea nemuzu, protoze naseptavac by mi pri pozadavku vymazal vsechny ostatni hodnoty v inputech.

Reseni by bylo vytvorit si input, ten obalit snippetem a pri ajaxovem odeslanim formulare a v pripade chyby ho naplnit chybovou hlaskou a snippet prekreslit.

Rad bych se zeptal, jak to resite vy?

Diky za rady

Felix
Nette Core | 1197
+
0
-

Zkousel jsi pouzit promennou $_form? IMHO by to mohlo fungovat.

{snippetArea regform}
    {form registerForm}
        {snippet errors}
        <p class="error" n:foreach="$_form->errors as $error">{$error}</p>
        {/snippet}

        {input ...}
        {input ...}
        {snippet autoCompleteSelect}{input autoCompleteSchool}{/snippet}
    {/form}
{/snippetArea}