Yii 2.0 How to generate form without
?

前端 未结 4 1222
抹茶落季
抹茶落季 2021-02-02 09:30
 \'contact-form\']); ?>
        field($model, \'email\',  [
                \'inputOptions\' => [          


        
相关标签:
4条回答
  • 2021-02-02 09:48

    You could simply use Html::activeTextInput() :

    <?= Html::activeTextInput($model, 'email', ['placeholder' => 'Ihre E-Mail Adresse', 'class' => 'newsletter-cta-mail']); ?>
    

    Or change ActiveForm::$fieldConfig configuration :

    ActiveForm::begin([
        'id' => 'contact-form',
        'fieldConfig' => [
            'options' => [
                'tag' => false,
            ],
        ],
    ]); 
    
    0 讨论(0)
  • 2021-02-02 09:56

    I have solved it like this....put tag as span.. also you can prepend icons infront of the box.

    <div id="login-box-inner">
        <?php $form = ActiveForm::begin([
            'id' => 'login-form',
            'options' => ['role'=>'form'],
    
            'fieldConfig' => [
                'options' => [
                    'tag' => 'span',
                ],
    
            ],
        ]); ?>
    
        <?= $form->field($model, 'username',[
            'template' => '
                <div class="input-group">
                    <span class="input-group-addon"><i class="fa fa-user emerald"></i></span>
                    {input}
                </div>
                {error}',
            'inputOptions' => [
                'placeholder' => 'Username ...',
                'class'=>'form-control',
            ]])
        ?>
    
    
        <?= $form->field($model, 'password', [
                'template' => '
                    <div class="input-group">
                        <span class="input-group-addon"><i class="fa fa-key emerald"></i></span>
                        {input}
                    </div>
                    {error}',
                'inputOptions' => [
                    'placeholder' => 'Password ...',
                    'class'=>'form-control',
                ]])->input('password')
        ?>
    
        <?php ActiveForm::end(); ?>
    
    0 讨论(0)
  • 2021-02-02 10:09
    <?= $form->field($model, 'email', [
        'template' => '{input}', // Leave only input (remove label, error and hint)
        'options' => [
            'tag' => false, // Don't wrap with "form-group" div
        ],
    ]) ?>
    
    0 讨论(0)
  • 2021-02-02 10:12

    or You could something like this (change div to span)

    
    
        $form = ActiveForm::begin([
        'id' => 'contact-form',
        'fieldConfig' => [
                            'template' => "{input}",
                            'options' => [
                                'tag'=>'span'
                            ]
        ]
        ]); 
    
    
    0 讨论(0)
提交回复
热议问题