【问题标题】:How to make date input field readonly in Cake PHP如何在 Cake PHP 中使日期输入字段只读
【发布时间】:2016-10-04 13:41:38
【问题描述】:

是否有任何标准方法可以在 CakePHP 中将日期输入字段设为只读。

我有以下代码:

echo $this->Form->input('testDate',array(
                            'label' => 'date',
                            'dateFormat' => 'DMY',
                            'minYear' => date('Y') - 20,
                            'maxYear' => date('Y') - 0
                        )
                    )

我尝试了以下方法:

echo $this->Form->input('testDate',array(
                            'label' => 'date',
                            'dateFormat' => 'DMY',
                            'minYear' => date('Y') - 20,
                            'maxYear' => date('Y') - 0,
                            'disabled' => 'disabled'
                        )
                    )

这很好用(使输入字段可禁用),但我当然不能 POST,所以我尝试了 'readonly' => 'readonly' 而不是以同样的方式禁用,但这是行不通的。我是否必须使用任何其他方式(例如 Javascript)?我在哪里犯错?谢谢大家的建议

【问题讨论】:

  • 试试这个 'echo $this->Form->input('testDate',array( 'label' => 'date', 'dateFormat' => 'DMY', 'minYear' => date('Y') - 20, 'maxYear' => date('Y') - 0, 'readonly' =>true ) );'
  • 嗨 Rohit,我也试过了 :(
  • cake2 还是 cake3?请检查标签
  • 没有添加JS,我用的是cake3,是不是蛋糕版问题?

标签: javascript php cakephp cakephp-3.0 cakephp-2.3


【解决方案1】:

试试这个

echo $this->Form->input('testDate',array(
                            'readyonly' => true
                        )
                    )

【讨论】:

    猜你喜欢
    • 2014-05-02
    • 2013-07-23
    • 1970-01-01
    • 1970-01-01
    • 2015-08-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-07-30
    相关资源
    最近更新 更多