You can try the following however, i don’t know if it will work
<?=
$form->field($model, 'from_date')->widget(\yii\widgets\MaskedInput::className(), [
'clientOptions' => [
'alias' => 'numeric',
'allowMinus'=>false,
'groupSize'=>3,
'radixPoint'=> ".",
'groupSeparator' => ',',
'autoGroup' => true,
'removeMaskOnSubmit' => true
//'unmaskAsNumber'=>true//dont know what this does
]
]);
?>
you can see all off the undocumented options here they start at line 70 and go to 95
If the above doesn’t work then you can try one of these three options.
-
You will have to write your own custom masked input mask (look at docs to see how)
-
Implement a before save function that strips the "." from the field
public function beforeSave($insert) {
//preform on both create and update
//removes commas and periods
$model->from_date = str_replace('.', '', $value);
//removes just periods
//$model->from_date =str_replace(['.', ','], '' , $value);
if (parent::beforeSave($insert)) {
return true;
} else {
return false;
}
}
- Create a rule to strip it.
//removes commas and periods
['from_date', 'filter', 'filter' => function($value) { return str_replace(['.', ','], '' , $value); }]
removes just periods
['from_date', 'filter', 'filter' => function($value) { return str_replace('.', '' , $value); }]
however, the rule may cause other validation issues. I’d personally write my own or try and find an option in the code that lets you strip it on save.