Kdyby / FormsReplicator

Other
30 stars 57 forks source link

Replicator doesn't work with select box with prompt #19

Closed janlanger closed 10 years ago

janlanger commented 10 years ago

Nette@dev, replicator@dev

When I use select in replicator, whith uses prompt (via setPrompt() function), the form cannot be submitted if the select has prompt value selected (the field is not required, so this should be okey)

Form submit ends with "Value '' is out of range of current items." - debugger - http://d.pr/f/wT5x

The problem was probably caused by this commit to nette - https://github.com/nette/nette/commit/1c59a8501e3cb629742c6fd355cd6f8584397a14

I noticed that select with prompt created directly on Form instance passes to setValue NULL, but select in Replicator passes empty string...

I was able to reproduce this error even on clean sandbox only with Kdyby/Replicator

$form = new \Nette\Application\UI\Form();
$samples = $form->addDynamic('samples', function(\Nette\Forms\Container $sample) {
 $sample->addText('code');
 $sample->addSelect('section', "", ['One', 'Two', 'Three'])
    ->setPrompt('---');
$sample->addSubmit('remove', 'Odebrat')
    ->addRemoveOnClick();
});
$samples->addSubmit('add', 'Přidat vzorek')->addCreateOnClick();
stekycz commented 10 years ago

I have met this error too.

fprochazka commented 10 years ago

@Quinix would you mind verifying that it's fixed?

janlanger commented 10 years ago

It works, thaks for the fix!