带有嵌套 ul 类 yii 框架的按钮
button with nested ul clases yii framework
我想要这个,但是使用 yii 框架:
<span class="btn default btn-file">
<span class="fileinput-new">Select image</span>
<span class="fileinput-exists">Change</span>
<input type="file" name="..."></input>
</span>
尝试这样做但行不通;
echo Button::widget([
'label' => 'Select Image',
'options' => ['class' => 'btn default btn-file'],
'options' => ['class' => 'fileinput-new'],
]);
我是 yii 框架的新手,我花了一些时间尝试这样做但没有成功。任何帮助将不胜感激
试试这个:
<?= Html::a('label', ['/controller/action'], ['class'=>'btn btn-primary']) ?>
希望它能如你所愿
要进行此输入,您可以像这样使用 ActiveForm(如果您有模型):
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'attribute')->fileInput() ?>
<div class="form-group">
<?= Html::submitButton('Submit') ?>
</div>
<?php ActiveForm::end() ?>
或 Html helper(如果您不想要模型):
<?php
use yii\helpers\Html;
?>
<?php $form = Html::beginForm(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= Html::fileInput('...') ?>
<div class="form-group">
<?= Html::submitButton('Submit') ?>
</div>
<?php Html::endForm() ?>
相信你看完文档后,适应样式不会有问题。两者都有 label
方法,允许您根据需要编辑标签。如果我不清楚某些事情,请告诉我。
如果你想在yii2中使用文件字段。创建一个表单并将您的字段放在表单中。
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($modelobj, 'fieldname')->fileInput() ?>
<?= Html::submitButton('Submit')?>
<?php ActiveForm::end() ?>
我想要这个,但是使用 yii 框架:
<span class="btn default btn-file">
<span class="fileinput-new">Select image</span>
<span class="fileinput-exists">Change</span>
<input type="file" name="..."></input>
</span>
尝试这样做但行不通;
echo Button::widget([
'label' => 'Select Image',
'options' => ['class' => 'btn default btn-file'],
'options' => ['class' => 'fileinput-new'],
]);
我是 yii 框架的新手,我花了一些时间尝试这样做但没有成功。任何帮助将不胜感激
试试这个:
<?= Html::a('label', ['/controller/action'], ['class'=>'btn btn-primary']) ?>
希望它能如你所愿
要进行此输入,您可以像这样使用 ActiveForm(如果您有模型):
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($model, 'attribute')->fileInput() ?>
<div class="form-group">
<?= Html::submitButton('Submit') ?>
</div>
<?php ActiveForm::end() ?>
或 Html helper(如果您不想要模型):
<?php
use yii\helpers\Html;
?>
<?php $form = Html::beginForm(['options' => ['enctype' => 'multipart/form-data']]); ?>
<?= Html::fileInput('...') ?>
<div class="form-group">
<?= Html::submitButton('Submit') ?>
</div>
<?php Html::endForm() ?>
相信你看完文档后,适应样式不会有问题。两者都有 label
方法,允许您根据需要编辑标签。如果我不清楚某些事情,请告诉我。
如果你想在yii2中使用文件字段。创建一个表单并将您的字段放在表单中。
<?php
use yii\widgets\ActiveForm;
?>
<?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]) ?>
<?= $form->field($modelobj, 'fieldname')->fileInput() ?>
<?= Html::submitButton('Submit')?>
<?php ActiveForm::end() ?>