Replicator/adDynamic vlastni render chyb

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
ali
Člen | 342
+
0
-

Prolezl sem tu snad vsechna vlakna na toto tema, ale nikde se mi nepodarilo najit odpoved nebo spis nikdo nenarazil na tento problem. Formular mam vytvoreny, zajaxovany, vsechno mi funguje tak jak ma, az na to, ze mi to nevypisuje chyby..

komponenta

protected function createComponentAddForm()
{
  $form = new Nette\Application\UI\Form;

  $presenter = $this;
  $invalidateCallback = function() use ($presenter)
  {
    $presenter->invalidateControl("addForm");
  };

  $order = $form->addDynamic("orders",function(Container $container) use ($invalidateCallback){
    $container->addText("order","Order:")
      ->setRequired();
    $container->addText("qty","Qty:")
      ->addRule(Form::INTEGER);
			$container->addSubmit("remove", "Remove")
      ->setAttribute("class","ajax")
				->addRemoveOnClick($invalidateCallback);
  },1);

		$order->addSubmit("add","[+]")
    ->setAttribute("class","ajax")
			->addCreateOnClick(true,$invalidateCallback);

  $form->addText("dept_code","Department code:")
    ->addRule(Form::LENGTH,6);

		$form->addSubmit("send","Save order")
			->setAttribute("class","ajax")
			->onClick[] = callback($this,"addFormSubmited");

  return $form;
}

sablona

{block content}
{control grid}
{snippet addForm}
 {form addForm}
  {control $form errors}
  <table>
   <tr>
    <td>{label dept_code /}</td><td>{input dept_code}</td>
   </tr>
  {foreach $form["orders"]->containers as $id => $order}
   <tr>
    <td>{label orders-$id-order /}</td><td>{input orders-$id-order}</td>
   </tr>
   <tr>
    <td>{label orders-$id-qty /}</td><td>{input orders-$id-qty}<span></span> {input orders-$id-remove}</td>
   </tr>
   {/foreach}
   <tr>
    <td>&nbsp;</td><td>{input orders-add}</td>
   </tr>
   <tr>
    <td>&nbsp;</td><td><br />{input send}</td>
   </tr>
  </table>
 {/form}
{/snippet}

zkousel jsem ruzne moznosti jak vypsat chyby, ale nikdy se nic neobjevi. Vidi nekdo neco co ja cely den prehlizim?

sKopheK
Člen | 207
+
0
-

A kde validujes? Kdyz mas u submitu

->onClick[] = callback($this,"addFormSubmited");

tak se proste po kliku vola ta metoda addFormSubmited a teprve v ni musis validovat, pokud se teda seredne nepletu.

ali
Člen | 342
+
0
-

validuji zde:

public function addFormSubmited(Nette\Application\UI\Form $form)
{
  if($form->isSubmitted())
  {
    $data["dept_code"] = $form["dept_code"]->value;

    forEach($form["orders"]->values as $order)
    {
      $data["order_qty"] = $order["qty"];
      $data["order"]     = $order["order"];
      $this->warehouseModel->insertNewOrder($data);
    }
  }
}

zkousel jsem ze submit buttonu odstranit ajax a chyby se zobrazuji, ale kdyz to zajaxuji tak ne, jako by se neprepisoval blok s chybami