doumen6532 2011-12-02 19:56
浏览 31
已采纳

cakephp输入类型编号

I have a mobile website form that I want to add type attributes to the inputs so that there correct keyboard format will pop up.

However in cakephp setting the type as number a textarea is created instead of the input and the type is not set.

Setting type as text does work.

How do I overide this and have cakephp just keep it as a text input with type=number?

<?php echo $form->input('phone',array('type' => 'number')); ?>

Result:

  <textarea id="UserCardExpires" rows="6" cols="30" name="data[User][card_expires]"class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset"></textarea>

This is ok:

  <?php echo $form->input('postcode' ,array('type' => 'text')); ?> 

Result

  <input type="text" id="UserPostcode" name="data[User][postcode]" class="ui-input-text ui-body-c ui-corner-all ui-shadow-inset">
  • 写回答

2条回答 默认 最新

  • dongli8862 2011-12-02 21:02
    关注

    On older versions of Cake, the Form helper won't automagically interpret $options['type'] as the HTML5 input-element type attribute. You have to force it by using "type" as an option on an explicit text element.

    Use the following:

    $form->text( 'phone', array( 'type' => 'number' ) );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度