date - Yii2 掩码输入日期时间,dd-mm-yyyy hh:mm
问题描述
我使用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)
?>
我正在尝试将“日期时间”掩码的行为更改为使用 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' => '__-__-____ __:__'
]
]
)
解决方案
您需要将 thealias
与placeholder
andseparator
选项一起用于以下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" => "-"
]
]
);
?>
在他的线程中查看更多详细信息
推荐阅读
- laravel - Laravel builder 按关系排序
- php - 限制 Wordpress 中的字符摘录
- java - Wildfly 服务 10.0 和 10.1 在 Windows 中无法停止
- wordpress - 对同一个按钮进行不同的点击触发
- angular - attr.data 在角度 5 上返回 null
- javascript - 如果我将变量 `close` 全局定义为 `0`,为什么变量`close` 被记录为`false`?
- sql - 如何通过汇总在组中添加平均列和总计?
- javascript - 在加载某些特定页面时隐藏页眉和页脚
- ansible - 从主机看不到 Ansible 环境变量
- python - 如何在文本中搜索特定段落?