我使用Yii2 maskedInput将日期时间格式转换为表单。
<?php
echo $form->field($modelIsoTanksDeliveryOrder, "open_stack", [
'template' => '{input}{error}{hint}'
])
->widget(\yii\widgets\MaskedInput::className(), [
'clientOptions' => [
'alias' => 'datetime',
],
'options' => [
'placeholder' => '__-__-____ __:__'
]
]
)->label(false)
?>
我正在尝试将“ datetime”掩码的行为更改为使用dd-mm-yyyy hh:mm而不是dd / mm / yyyy hh:mm。
我在JS RobinHerbots上发现了配置 但是仍然失败了
->widget(\yii\widgets\MaskedInput::className(), [
'clientOptions' => [
'alias' => 'dd-mm-yyyy',
'separator' => "-",
],
'mask' => '1-2-y h:s',
'options' => [
'placeholder' => '__-__-____ __:__'
]
]
)
答案 0 :(得分:1)
您需要为alias
使用placeholder
以及separator
和clientOptions
选项,如下所示
<?php echo
$form->field(
$modelIsoTanksDeliveryOrder, "open_stack", [
'template' => '{input}{error}{hint}'
]
)->widget(
\yii\widgets\MaskedInput::class, [
'mask' => "1-2-y h:s",
'clientOptions' => [
'alias' => 'datetime',
"placeholder" => "dd-mm-yyyy hh:mm",
"separator" => "-"
]
]
);
?>
详细了解他的thread