CakePHP 3 输入类型文件设计
CakePHP 3 input type file design
我想在输入类型文件之前设置跨度。这是我现有的代码。
<?= $this->Form->input('logo', ['onchange'=>'onFileImage(this);',
'label' => false,
'type' => 'file',
'class'=>'']);?>
<lable class="inva_img"></lable>
我希望输出类似于下面的代码。
<span class="btn btn-default btn-file">
<span>Choose file</span>
<input type="file" name="logo" id="logo" onchange="onFileImage(this);" />
</span>
您可以通过以下代码完成
<?php
echo $this->Form->input('logo', [
'templates' => [
'inputContainer' => '<span class="input file required btn btn-default input {{type}}{{required}}"><span>Choose file</span>{{content}}</span>',
],
'onchange'=>'onFileImage(this);',
'class' => 'form-control',
'type' => 'file',
'label' => false
]);
?>
详情请看ndm ans.
尝试 before/after 选项
echo $this->Form->input('field_name', array(
'before' => '-before-',
'after' => '-after-',
'between' => '-between-'
));
在 cakephp 中阅读更多内容 book。
为 cakephp2 试试这个:
<?php
$this->Form->input('logo', ['onchange'=>'onFileImage(this);',
'label' => false,
'before' => '<span class="btn btn-default btn-file"><span>Choose file</span>',
'after' => '</span>',
'type' => 'file',
'class'=>'']);
希望cakephp3也有类似的概念
HTH.
<span class="btn btn-default btn-file">
<span>Choose file</span>
<input type="file" name="logo" id="logo" onchange="onFileImage(this);" />
</span>
只需将 <input>
标记字段替换为 cakephp 标准,其他代码保持不变。这是转换:
<span class="btn btn-default btn-file">
<span>Choose file</span>
<?php
echo $this->Form->input(
'logo', array(
'id' => 'logo',
'type' => 'file',
'onchange' => 'onFileImage(this);'
)
);
?>
</span>
我想在输入类型文件之前设置跨度。这是我现有的代码。
<?= $this->Form->input('logo', ['onchange'=>'onFileImage(this);',
'label' => false,
'type' => 'file',
'class'=>'']);?>
<lable class="inva_img"></lable>
我希望输出类似于下面的代码。
<span class="btn btn-default btn-file">
<span>Choose file</span>
<input type="file" name="logo" id="logo" onchange="onFileImage(this);" />
</span>
您可以通过以下代码完成
<?php
echo $this->Form->input('logo', [
'templates' => [
'inputContainer' => '<span class="input file required btn btn-default input {{type}}{{required}}"><span>Choose file</span>{{content}}</span>',
],
'onchange'=>'onFileImage(this);',
'class' => 'form-control',
'type' => 'file',
'label' => false
]);
?>
详情请看ndm ans.
尝试 before/after 选项
echo $this->Form->input('field_name', array(
'before' => '-before-',
'after' => '-after-',
'between' => '-between-'
));
在 cakephp 中阅读更多内容 book。
为 cakephp2 试试这个:
<?php
$this->Form->input('logo', ['onchange'=>'onFileImage(this);',
'label' => false,
'before' => '<span class="btn btn-default btn-file"><span>Choose file</span>',
'after' => '</span>',
'type' => 'file',
'class'=>'']);
希望cakephp3也有类似的概念
HTH.
<span class="btn btn-default btn-file">
<span>Choose file</span>
<input type="file" name="logo" id="logo" onchange="onFileImage(this);" />
</span>
只需将 <input>
标记字段替换为 cakephp 标准,其他代码保持不变。这是转换:
<span class="btn btn-default btn-file">
<span>Choose file</span>
<?php
echo $this->Form->input(
'logo', array(
'id' => 'logo',
'type' => 'file',
'onchange' => 'onFileImage(this);'
)
);
?>
</span>