【问题标题】:How do you set a textInput to readOnly in Yii2?如何在 Yii2 中将 textInput 设置为只读?
【发布时间】:2017-03-02 08:01:44
【问题描述】:

如何将textInput 设置为readOnly?我有下面的示例代码:

<?= $form->field($model, 'GrossPay')->textInput(['id'=>'GrossPay','readonly'=> true])?>

【问题讨论】:

  • 这正是readonly 应该这样做的方式。您确定要查找的是readonly 而不是disabled
  • 我想阻止用户在 textInput 中输入数据,因为该 textInput 的值 (GrossPay) 可以使用 Javascript 计算。
  • 好的,所以readonly 是。它就像你的例子一样工作。
  • 谢谢。它现在可以工作了。
  • 问题是文件的路径

标签: yii2 readonly textinput


【解决方案1】:

readOnly 不是 只读,但在这里并没有什么不同。

<?= $form->field($model, 'GrossPay')->textInput(['id'=>'GrossPay','readonly'=> true])?> 

【讨论】:

  • 其实是readonly,如W3C spec。 HTML 属性无论如何都不区分大小写,但最好将它们保持小写。
  • @Bizley。在回答之后意识到,这就是为什么在那之后编辑。
  • @Ermene。这应该可以,你的代码也没有错误。经过测试
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-05-17
  • 1970-01-01
  • 2013-03-30
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多