I’m writing a web app to track cell phone hardware. Some hardware has an IMEI that’s 14 characters long and others are 15 characters long. I’m using CMaskedTextFields to try to keep everything formatted consistently, and because it is easier to read.
I ran across this problem today after trying to import some old data into the database. Any data that doesn’t exactly match my mask doesn’t get displayed, even though it is in the database. Here’s the code I’m using for the CMaskedTextField widget:
$this->widget('CMaskedTextField', array(
'model' => $model,
'value' => $model->isNewRecord ? $model->imei : '',
'attribute' => 'imei',
'mask' => '*** *** *** *** ***',
'placeholder'=>'',
'htmlOptions' => array('class' => 'form-control','placeholder'=>'IMEI','size'=>19,'maxlength'=>19)
)
);
I also tried setting this mask:
'mask' => '*** *** *** *** ?',
When I did that, it cut off everything from the 5th grouping of numbers…
Is there a way to allow multiple masks?
What’s the best way to handle this?