S
S
Sergey Beloventsev2018-02-06 11:33:59
Yii
Sergey Beloventsev, 2018-02-06 11:33:59

Question about using a mask?

what is the essence of the mask form the phone

<?= $form->field($model, 'phone')->widget(\yii\widgets\MaskedInput::className(), [
            'mask' => '+9(999)-999-99-99',
            'clearIncomplete'=>true
    ]) ?>

but I need to send it to me exactly as a number without all this tinsel + () - the question is how this can be organized, given the validation.
And in order not to get up twice, how can you then display these phones with a mask to clients? The mask is created purely for the convenience of clients, not for storage in the database.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim Timofeev, 2018-02-06
@webinar

write logic in beforeSave and afterFind. Accordingly, clean from brackets, the "+" sign and spaces before saving and add after the selection.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question