Good day
There is a piece of code for SELECT fields (YII2 framework)
->dropDownList($structure_enum, [
'class' => 'form__select',
'style' => 'width: 100%;',
])
Ie roughly speaking, there is an array of data
As this array to pass or not another key is the condition, not the city the extra code above
Ie write something like
->dropDownList($structure_enum, [
'class' => 'form__select',
'style' => 'width: 100%;',
$structure_strict ? 'disabled' => 'disabled' : ",
])
The code itself is not working, but for example clear
P. S Please do not offer the type of option
$a = [
'class' => 'form__select',
'style' => 'width: 100%;',
];
if ($structure_strict) $a ['disabled'] = 'disabled';
.....
->dropDownList($structure_enum, $a)
Am interested in the question of the brevity of the record
P. S
Thank you all for the answers
In General or using array_merge or through the addition of arrays
Still just as cumbersome
But if there are more elegant solutions, I will do so :) - malvina.Yundt commented on July 9th 19 at 11:21
In the General case, applicable to Your version
But if you use YII2, then purely for me, you can specify false as the value of the disabled element will not be created :)
In General, live and learn ) - malvina.Yundt commented on July 9th 19 at 11:24