Kdyby / FormsReplicator

Other
30 stars 57 forks source link

not accepting POST data when addDynamic() called as the first form item #8

Open xpavp03 opened 11 years ago

xpavp03 commented 11 years ago

Hi Filip, here's a pseudo code that demonstrates the issue:

    $form = new NAppForm($parent, $name);

    $form->addDynamic('players', function (NFormContainer $container) {
      $container->addText('rank');
    });

    $form->addHidden('tournament_id');

When defined like this, I can set default values, render the form manually with {input players-$playerId-rank} however, it won't load submitted values into players upon submit because $this->getComponents() in NFormContainer/getValues() loop returns nothing. So when I call $form->values in my processing method I get an empty iterator/array for players.

If however, I place the hidden item before the dynamic one, everything works fine:

    $form = new NAppForm($parent, $name);

    $form->addHidden('tournament_id');

    $form->addDynamic('players', function (NFormContainer $container) {
      $container->addText('rank');
    });

Please let me know if you're able to replicate the issue. If not, I would send a full test app (probably next month though, I'm short of time right now).

Nette Framework 2.0.8 (revision b7f6732 released on 2013-01-01)