V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
lsoknet
V2EX  ›  问与答

yii2 怎样为某个 field 单独指定 template?

  •  
  •   lsoknet · 2018-04-28 11:41:35 +08:00 · 977 次点击
    这是一个创建于 2212 天前的主题,其中的信息可能已经有所发展或是发生改变。

    如题,比方说有两个 input,每个 input 后面的样式是不同的,怎样指定 template 呢?

    [ 'template' => '
    {error}{input}
    '] ]); field($model, 'phone')->textInput(['placeholder' => '手机号']); ?> field($model, 'password')->passwordInput(['placeholder' => '密码']); ?>

    原始 html 是这样的:

    <input type="text" name="phone" class="form-control" placeholder="手机号">
    <input type="password" name="password" class="form-control" placeholder="密码">
    1 条回复    2018-04-28 12:31:40 +08:00
    zhoushiya
        1
    zhoushiya  
       2018-04-28 12:31:40 +08:00 via Android
    [ 'template' => '
    {error}{input}
    '] ]); field($model, 'phone')->textInput(['placeholder' => '手机号','class '='a']); ?> field($model, 'password')->passwordInput(['placeholder' => '密码','class '='b']); ?>
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   1020 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 19:31 · PVG 03:31 · LAX 12:31 · JFK 15:31
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.