Reputation: 41
I'm using ColorInput (widget from krajee). I have one table with 2 columns (Color_1 and Color_2) and i'm trying show all colors in one page.
foreach($array as $value)
{
echo $form->field($value, 'Color_1')->widget(ColorInput::classname(), [])->label(false);
}
After that, only first color works.
Anyone have some idea to solve the problem? Thank you.
Upvotes: 1
Views: 91
Reputation: 41
I solved problem changing the name of each field:
echo $form->field($template, "Color1[{$i}]")->widget(ColorInput::classname(), [
'showDefaultPalette' => true,
'pluginOptions' => [
'showPaletteOnly' => true,
'showSelectionPalette' => true,
'allowEmpty' => false,
]
])->label(false);
Upvotes: 2
Reputation: 3059
I don't know about yii
, but it looks like $form->field() ...
does not return
a field, but configures the field. So you configure the same field 4 times. Did you try to echo
something more and look at the resulting html
code?
foreach($array as $value)
{
echo $form->field($value, 'Color_1')->widget(ColorInput::classname(), [])->label(false);
echo ' separator ';
}
Upvotes: 0