How to use the multiplier for editing

オープン
#104 コメント 5 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
25/100
issue の種類
ドキュメント
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
php
領域
backend

調査の方向性

The issue names no target file or test; start by reviewing the repository documentation and the addMultiplier usage shown in the PHP snippet. Confirm how existing values should populate multiplier containers during editing and document a correct, reproducible example. Done means a newcomer can follow the documented editing workflow without needing clarification.

索引モデルが issue の本文から書いたものです。

説明

question

Hello
I'm trying to use a multiplier in a data editing form.
According to the records in the database, the appropriate number of Multiplier elements must be displayed.

Unfortunately, I don't know how to properly access the multiplier components.

Can you state the correct use of the multiplier for editing?

$defHeader = json_decode($defVals->header, true);
            
$multiplier = $form->addMultiplier('multiplier', function (\Nette\Forms\Container $container, \Nette\Forms\Form $form) {
    $arrHlavicka = $this->webhookModel->getHlavicka(['stav'=>1])->fetchPairs("nazev", "nazev");

    $container->addSelect('hlavicka', 'Hlavička',$arrHlavicka)
        ->setHtmlAttribute('class', 'form-control')
        ->setHtmlAttribute("placeholder", 'Vyberte hlavičku')
        ->setPrompt('Vyberte hlavičku');

    $container->addText('hlavickaval', 'Request Header')
        ->setHtmlAttribute('class', 'form-control')
        ->setHtmlAttribute("placeholder", 'Hodnota hlavičky');    
}, count($defHeader));   

$multiplier->addCreateButton('Přidat hlavičku')
      ->addClass('btn btn-success');

foreach($defHeader as $k => $v){
    $hlavicka[] = [ 'hlavicka' => $k, 'hlavickaval' => $v ];
}

foreach ($multiplier as $index => $container) {
    $hlavicka = $container->getComponent('hlavicka');
    $hlavickaval = $container->getComponent('hlavickaval');
    
    // Nastavení výchozích hodnot
    $hlavicka->setDefaultValue($hlavicka[$index]['hlavicka']);
    $hlavickaval->setDefaultValue($hlavicka[$index]['hlavickaval']);

    // Přidání tlačítka RemoveButton
    $container->addRemoveButton('Smazat')
              ->addClass('btn btn-danger');
}

Thank you
Thomas

主要言語
PHP
スター
29
フォーク
20
PR マージ指標
30日以内にマージされた PR はありません

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

contributte/forms-multiplier のほかの issue

contributte/forms-multiplier の issue をすべて見る

似ている issue

PHP の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。