Problém s Multiplier ve form

- jAkErCZ
 - Člen | 324
 
Zdravím, chtěl jsem využít možnost přidání více věcí do formu a dostal jsem nasměřování na Multiplier který se mi zalíbil ale našel jsem chybu se kterou si nevím rady…
Mám
 protected function createComponentInquiryForm()
    {
        $form = new Form;
        $copies = 1;
        $maxCopies = 10;
        $multiplier = $form->addMultiplier('multiplier', function (\Nette\Forms\Container $container, \Nette\Forms\Form $form) {
            $container->addRadioList('atribut', '', ([
                'window' => 'Okna',
                'door' => 'Dveře',
                'balcony' => 'Balkón',
                'gate' => 'Vrata',
            ]))->setAttribute('class', 'wrap-input100 rs1-wrap-input100 validate-input')->setRequired();
            $container->addText('width', '')->setRequired();
            $container->addText('height', '')->setRequired();
            $container->addText('pieces', '')->setRequired();
        }, $copies, $maxCopies);
        $multiplier->addCreateButton('Add'); // add one container
        $form->addText('first_name','')->setRequired();
        $form->addText('last_name', '')->setRequired();
        $form->addText('email', '')->setRequired();
        $form->addText('phone', '')->setRequired();
        $form->addTextArea('message', '')->setRequired();
        $form->addSubmit('submit', '');
        $form->onSuccess[] = [$this, 'inquiryFormSucceeded'];
        return $form;
    }
A v šabloně volám
<form n:name="inquiryForm" class="contact100-form validate-form" role="form">
                <span class="contact100-form-title">
					Ozveme se Vám
				</span>
                <ul class="required" n:if="$form->hasErrors()">
                    <li n:foreach="$form->errors as $error">{$error}</li>
                </ul>
                <label class="label-input100" for="atribut">Vyberte si produkt *</label>
                <div n:multiplier="multiplier">
                    {foreach $form['atribut']->items as $key => $label}
                        {label atribut:$key}
                            {input atribut:$key} <img src="{$basePath}/images/contact/{$key}.png"
                                                      style="display: table-cell !important;    width: 100px;">
                        {/label}
                    {/foreach}
                    <label class="label-input100" for="width">Parametry *</label>
                    <div class="wrap-input100 rs1-wrap-input100 validate-input" data-validate="Type width">
                        <input n:name="width" id="width" class="input100" type="number" placeholder="Šířka (1000mm)">
                        <span class="focus-input100"></span>
                    </div>
                    <div class="wrap-input100 rs2-wrap-input100 validate-input" data-validate="Type height">
                        <input n:name="height" id="height" class="input100" type="number" placeholder="Výška (1000mm)">
                        <span class="focus-input100"></span>
                    </div>
                    <div class="wrap-input100 rs3-wrap-input100 validate-input" data-validate="Type pieces">
                        <input n:name="pieces" id="pieces" class="input100" type="number" placeholder="Počet kusů">
                        <span class="focus-input100"></span>
                    </div>
                </div>
                <label class="label-input100" for="first_name">Vaše jméno *</label>
                <div class="wrap-input100 rs1-wrap-input100 validate-input" data-validate="Type first_name">
                    <input n:name="first_name" id="first_name" class="input100" type="text"
                                               placeholder="Vaše jméno">
                    <span class="focus-input100"></span>
                </div>
                <div class="wrap-input100 rs2-wrap-input100 validate-input" data-validate="Type last_name">
                    <input n:name="last_name" id="last_name" class="input100" type="text"
                                              placeholder="Vaše příjmení">
                    <span class="focus-input100"></span>
                </div>
                <label class="label-input100" for="email">Váš e-mail *</label>
                <div class="wrap-input100 validate-input required" data-validate="email">
                    <input n:name="email" id="email" class="input100" type="email"
                                          placeholder="Váš mail vzor@vozor.cz">
                    <span class="focus-input100"></span>
                </div>
                <label class="label-input100" for="phone">Váš telefon *</label>
                <div class="wrap-input100">
                    <input n:name="phone" id="phone" class="input100" type="number" placeholder="+420">
                    <span class="focus-input100"></span>
                </div>
                <label class="label-input100" for="message">Poznámka *</label>
                <div class="wrap-input100 validate-input" data-validate="Message is required">
                        <textarea n:name="message" id="message" class="input100"
                                                   placeholder="Vložte sem poznámu k poptávce."></textarea>
                    <span class="focus-input100"></span>
                </div>
                <div class="container-contact100-form-btn">
                    <button n:name="submit" type="submit" class="contact100-form-btn">Nezávazně poptat</button>
                </div>
            </form>
Ale u
<div n:multiplier="multiplier">
                    {foreach $form['atribut']->items as $key => $label}
                        {label atribut:$key}
                            {input atribut:$key} <img src="{$basePath}/images/contact/{$key}.png"
                                                      style="display: table-cell !important;    width: 100px;">
                        {/label}
                    {/foreach}
Mi laděnka hází chybu -->
Component with name 'atribut' does not exist.
řádek: {foreach $form[‚atribut‘]->items as $key ⇒ $label}
A teď se chci zeptat v čem dělám chybu? Jelikož dost lidí mi řeklo že by to prostě mělo fungovat…
Díky

- Ondřej Kubíček
 - Člen | 494
 
protože ve $form žádný prvek atribut není, ten je až
v tom multiplier prvku, takže by to mělo být asi nějak takhle
{foreach $form['multiplier']->items as $key => $label}
(hádám, neznám to extension)

- jAkErCZ
 - Člen | 324
 
Ondřej Kubíček napsal(a):
protože ve
$formžádný prvek atribut není, ten je až v tom multiplier prvku, takže by to mělo být asi nějak takhle{foreach $form['multiplier']->items as $key => $label}(hádám, neznám to extension)
Nad touto variantou jsem též přemýšlel ale
Cannot read an undeclared property WebChemistry\Forms\Controls\Multiplier::$items.
Jinak Extension
- WebChemistry\Forms\Controls\DI\MultiplierExtension
					Editoval jAkErCZ (21. 3. 2018 15:49)

- Ondřej Kubíček
 - Člen | 494
 
jo jasně to vrací container šak
{foreach $form['multiplier']->getContainers() as $container}
	{foreach $container['atribut']->items as $key => $label}
    	{label atribut:$key}
        {input atribut:$key}
		...
   {/foreach}
{/foreach}
					Editoval Ondřej Kubíček (21. 3. 2018 16:28)

- jAkErCZ
 - Člen | 324
 
Ondřej Kubíček napsal(a):
jo jasně to vrací container šak
{foreach $form['multiplier']->getContainers() as $container} {foreach $container['atribut']->items as $key => $label} {label atribut:$key} {input atribut:$key} ... {/foreach} {/foreach}
Ještě jsem našel chybu že když si přidám nový produkt pomocí multiplieru stane se tohle…
Jak tohle vyřeším?