Kdyby\Replicator – prodavanie dalsich stlpcov
- duskohu
- Člen | 778
Ahojte pouzivam Kdyby\Replicator a potreboval by som okrem replikovania
riadkov replikovat aj jeden stlpec ktory som dal do kontajneru items, cize by
som mal stlce 1,2,3,… Uvazoval som ze pridam dalsi button, , ale ako dalej
neviem.
Neviete mi poradit ako na to?
$specifications = $form->addDynamic('specifications',
function (Container $specifications) {
$specifications->addText('name', 'Názov');
// tento field potrebujem replikovat
$items = $specifications->addContainer('items');
$items->addText('1', '1');
$specifications->addSubmit('remove', 'Odstrániť')
->setValidationScope(false)
->onClick[] = function (SubmitButton $button) {
/** @var \Kdyby\Replicator\Container $gallery */
$specifications = $button->parent->parent;
$specifications->remove($button->parent, true);
if ($this->presenter->isAjax()) {
$this->redrawControl();
}
};
}, 0
);
// pridavanie riadku
$specifications->addSubmit('add', 'Pridať')
->setValidationScope(false)
->onClick[] = function (SubmitButton $button) use ($specifications) {
$specifications->createOne();
if ($this->presenter->isAjax()) {
$this->redrawControl();
}
};
// pridavanie stlpca
$form->addSubmit('addColumn', 'Add column')
->setValidationScope(false)
->onClick[] = function (SubmitButton $button){
//....
if ($this->presenter->isAjax()) {
$this->redrawControl();
}
};
Editoval duskohu (17. 1. 2020 18:10)
- galab
- Backer | 74
Něco podobného jsem tvořil – steps jsou řádky, které obsahují milestones jako sloupce.
$steps = $form->addDynamic('steps', function (Container $step) {
$step->addText('title', 'Step name')->setRequired('Add step name');
$step->addSubmit('removeS','Remove step')
->setValidationScope([])
->addRemoveOnClick();
$mstones = $step->addDynamic('mstones', function (Container $mstone) {
$mstone->addText('title', 'Milestone title')->setRequired('Add milestone title');
$mstone->addSubmit('removeM','Remove milestone')
->setValidationScope([])
->addRemoveOnClick();
}, 1);
$mstones->addSubmit('addM', 'Add milestone')->addCreateOnClick();
}, 1);
Vypadalo to nějak takto – https://ctrlv.cz/Ldz2
Editoval galab (17. 1. 2020 22:18)