E
E
Elsevar Rizayev2017-01-13 17:42:44
Yii
Elsevar Rizayev, 2017-01-13 17:42:44

How to remove html tags in Yii2?

<?= $form->field($model, 'LastName')->textInput()
strip_tags() doesn't help
with options field encode => true also
HTMLPurifier
Nothing helped.
I have a form, the user enters data, I need to remove all tags before submitting. Maybe I'm not right there?!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-01-13
@EllPro

strip_tags() doesn't help

it can't be, you're just putting it in the wrong place. Studio code.
This is what should work:
<?php $model->LastName = strip_tags($model->LastName); ?>
<?= $form->field($model, 'LastName')->textInput(); ?>

But it's better to do it in the model and use camelCase (instead of LastName - lastName)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question