@art_guzev

Как присвоить input определенному объекту?

В корзине у каждого блюда есть input, чтобы привязать определенный input к блюду, добавляю к name ID блюда, получается что для каждого блюда input со своим name.
<input name="comment-in-order{{input[0].id}}" cols="30" rows="10" placeholder="Для удобства укажите фамилию или имя для кого выбрано блюдо">

5cb0c9b642309039280283.jpeg
Получаю на сервере:
$request->get('comment-in-order'.$input[$i][0]->getId().'')

5cb0cad2e85d9532081346.png
но отправляет только последний коммент
Как сделать чтобы отправляло комментарии для всех блюд?
Вот полностью блок блюда html
{%for input in input%}
          <div class="busket-block__order">
              <div class="order-block">
                  <div class="ob__logo">
                    <img src="{{input[0].img}}" alt="">
                    <div class="ob__header">
                        <h3>{{input[0].name}}</h3>
                    </div>
                  </div>
                  <div class="ob__order-info">
                    <div class="oi__top">
                      <div class="ob__kkal">
                          <p><span class="kkal">{{input[0].kkal}}</span><br>ккал</p>
                      </div>
                      <div class="ob__count">
                          <div class="count_order">
						  <form method="POST" id="minus{{input[0].id}}">
						  <input style="display:none" name="minus" value="{{input[0].id}}">
                          <p  onclick="call1('#minus{{input[0].id}}');" class="co__minus">-</p>
						   </form>  
                              <div class="co__number">{{input[0].kol}}</div>
							  <form method="POST" id="plus{{input[0].id}}">
									<input style="display:none" name="plus" value="{{input[0].id}}">									
                                   <p class="co__plus" onclick="call2('#plus{{input[0].id}}');">+</p>
							  </form>
                          </div>
                      </div>
                      <div class="ob__price-one">
                          <p><span class="price">{{input[0].cost}}</span><br>за шт.</p>
                      </div>
                      <div class="ob__price">
                          <p><span class="last-price">5</span><br>Сумма</p>
                      </div>  
					   <form method="POST" id="delete{{input[0].id}}">
                      <div class="ob__delete" onclick="call3('#delete{{input[0].id}}');">
									<input style="display:none" name="delete" value="{{input[0].id}}">
                        <span>x</span>
                      </div>
		   </form>
                    </div>
                   <form action="/busket" method="POST">
                    <div class="oi__bottom">
                        <input name="comment-in-order{{input[0].id}}" cols="30" rows="10" placeholder="Для удобства укажите фамилию или имя для кого выбрано блюдо">
                    </div>
                  </div>
              </div>
          </div>
		  {%endfor%}

и блок php:
{
	$messege2="";
			for($i=0;$i<count($input);$i++){
				
				
			    $messege2=$messege2.'
			     <tr>
    <td style="width: 175px;"><img class="center  autowidth " align="center" border="0" src="https://винегрет.бел/'.$input[$i][0]->getImg().'" alt="Image" title="Image" style="outline: none;text-decoration: none;-ms-interpolation-mode: bicubic;clear: both;display: block !important;border: 0;height: auto;float: none;width: 100%;max-width: 125px" width="125" /></td>
    <td style="width: 175px;"><center>'.$input[$i][0]->getName().'</center></td>
	<td style="width: 175px;"><center>'.$input[$i][0]->kol.'</center></td>
	<td style="width: 175px;"><center>'.$request->get('comment-in-order'.$input[$i][0]->getId().'').'</center></td>
  </tr>
			    ';
			}
  • Вопрос задан
  • 72 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы