Answer the question
In order to leave comments, you need to log in
How to remove name repetitions?
There is a list of ingredients, at the top of the fields there is the name of the dish to which the ingredient belongs, please tell me how to make sure that the name of the dish does not repeat, but is displayed only once!?
There is this:
And to do this:
My code in the view:
<?php foreach ($values as $index => $value): ?>
<div class="disabled"><?=$value->valuesAttribute->name?></div>
<?=$form->field($value, "[$index]name")->label(false);?>
<?php endforeach; ?>
Answer the question
In order to leave comments, you need to log in
$label='';
foreach ($values as $index => $value):
if ($label != $value->valuesAttribute->name) {
$label = $value->valuesAttribute->name;
?>
<div class="disabled"><?=$value->valuesAttribute->name?></div>
<?php
}
....
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question