Reputation: 172
How can disable encode html
in ActiveForm::Dropdown
active form Yii2?
I want to create a select html tag
that shows multilevel data so that children make fixed padding than its parents. So, I create an array like this:
$items = [
'Computer'
' Hardware'
' Software',
' Programming'
'&nbps; C#'
];
But space
is removed and &nbps;
encoded and both not worked. We can use pure html tag, but how can create it using Yii2::ActiveField?
Note that we can encode items before calling widget based on our conditions.
There is any idea?!
Upvotes: 0
Views: 773
Reputation: 535
To retain the spaces,
echo $form->field($model, 'attribute')->dropDownList($data, [
'encodeSpaces' => true,
]);
Upvotes: 0