Skip to content

Jak správně předat setDefaults z Action #54

Open
@jAKErCZ

Description

Čau,
mám dotaz snažím se přijít na to jak správně z Action metody nastavit multiplieru defaultní hodnoty tak jako se klasicky dělá.

viz...

 $this['eventTermForm']->setDefaults([
                    'terms_id' => $terms->terms_id,
                    'event_id' => $terms->event_id,
                    //'date' => $terms->date,
                    'price' => $terms->price,
                    'capacity' => $terms->capacity
                ]);

A formulář

protected function createComponentEventTermForm() {
        $copies = 1;
        $maxCopies = 7;
        $form = new Form();
        $form->addHidden('terms_id');
        $form->addSelect('event_id', '', $this->termsRepository->getSelectEvent())
            ->setPrompt('Vyberte Lekci')
            ->setRequired('Lekce je povinná!');
        $multiplier = $form->addMultiplier('multiplier', function (\Nette\Forms\Container $container, \Nette\Forms\Form $form) {
            $container->addText('date')
                ->setRequired('Datum je povinné!');
        }, $copies, $maxCopies);
        $multiplier->addCreateButton('Přidat další datum')
            ->addClass('btn btn-primary');
        $multiplier->addRemoveButton('Odstranit datum')
            ->addClass('btn btn-danger');
        $form->addText('price')
            ->setRequired('Cena je povinná!');
        $form->addText('capacity')
            ->setRequired('Kapacita je povinná!');
        $form->addCheckbox('all');
        $form->addSubmit('send');
        $form->onSuccess[] = [$this, 'eventTermFormSucceeded'];

        return $form;
    }

Hledal jsem nějaké řešení ale nic moc jsem nenašel díky moc...

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions