lsoknet
V2EX  ›  问与答

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

  •  
  •   lsoknet · Apr 28, 2018 · 1344 views
    This topic created in 3028 days ago, the information mentioned may be changed or developed.

    如题,比方说有两个 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 replies    2018-04-28 12:31:40 +08:00
    lcnr
        1
    lcnr  
       Apr 28, 2018 via Android
    [ 'template' => '
    {error}{input}
    '] ]); field($model, 'phone')->textInput(['placeholder' => '手机号','class '='a']); ?> field($model, 'password')->passwordInput(['placeholder' => '密码','class '='b']); ?>
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   916 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 20:33 · PVG 04:33 · LAX 13:33 · JFK 16:33
    ♥ Do have faith in what you're doing.