fastadmin 的form视图组件

//千万别忘记在对应的JS方法中添加代码Form.api.bindevent("form[role=form]");进行组件初始化,否则部分组件会不生效
 
//生成Token
Form::token() 
//Label标签
Form::label(string $name, string $value = null, array $options = []) 
//按类型生成文本框
Form::input($type, $name, string $value = null, array $options = [])
//普通文本框 
Form::text(string $name, string $value = null, array $options = []) 
//密码文本框
Form::password(string $name, array $options = []) 
//隐藏文本框
Form::hidden(string $name, string $value = null, array $options = [])
//Email文本框 
Form::email(string $name, string $value = null, array $options = []) 
//URL文本框
Form::url(string $name, string $value = null, array $options = []) 
//文件组件
Form::file(string $name, array $options = []) 
//多行文本框
Form::textarea(string $name, string $value = null, array $options = []) 
//富文本编辑器
Form::editor(string $name, string $value = null, array $options = []) 
//下拉列表组件
Form::select(string $name, array $list = [], string $selected = null, array $options = []) 
//下拉列表组件(多选)
Form::selects(string $name, array $list = [], string $selected = null, array $options = []) 
//下拉列表组件(友好)
Form::selectpicker(string $name, array $list = [], string $selected = null, array $options = []) 
//下拉列表组件(友好)(多选)
Form::selectpickers(string $name, array $list = [], string $selected = null, array $options = []) 
//动态下拉列表组件
Form::selectpage(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) 
//动态下拉列表组件(多选)
Form::selectpages(string $name, string $value, string $url, string $field = null, string $primaryKey = null, array $options = []) 
//城市选择组件
Form::citypicker(string $name, string $value, array $options = []) 
//开关组件
Form::switcher(string $name, string $value, array $options = []) 
//日期选择组件
Form::datepicker(string $name, string $value, array $options = []) 
//时间选择组件
Form::timepicker(string $name, string $value, array $options = []) 
//日期时间选择组件
Form::datetimepicker(string $name, string $value, array $options = []) 
//日期区间组件
Form::daterange(string $name, string $value, array $options = []) 
//时间区间组件
Form::timerange(string $name, string $value, array $options = []) 
//日期时间区间组件
Form::datetimerange(string $name, string $value, array $options = []) 
//字段列表组件
Form::fieldlist(string $name, string $value, string $title = null, string $template = null, array $options = []) 
//联动组件
Form::cxselect(string $url, array $names = [], array $values = [], array $options = []) 
//选择数字区间
Form::selectRange(string $name, string $begin, string $end, string $selected = null, array $options = []) 
//选择年
Form::selectYear(string $name, string $begin, string $end, string $selected = null, array $options = []) 
//选择月
Form::selectMonth(string $name, string $selected = null, array $options = [], string $format = '%m') 
//单个复选框
Form::checkbox(string $name, string $value = '1', string $checked = null, array $options = []) 
//一组复选框
Form::checkboxs(string $name, array $list = [], string $checked = null, array $options = []) 
//单个单选框
Form::radio(string $name, string $value = null, string $checked = null, array $options = []) 
//一组单选框
Form::radios(string $name, array $list = [], string $checked = null, array $options = []) 
//上传图片组件
Form::image(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 
//上传图片组件(多图)
Form::images(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 
//上传文件组件
Form::upload(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 
//上传文件组件(多文件)
Form::uploads(string $name = null, string $value, array $inputAttr = [], array $uploadAttr = [], array $chooseAttr = [], array $previewAttr = []) 
//表单button
Form::button(string $value = null, array $options = []) 

完整示例

<form id="add-form" class="form-horizontal" role="form" data-toggle="validator" method="POST" action="">
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('文本框')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::text('row[text]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('多行文本框')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::textarea('row[textarea]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('富文本编辑器')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::editor('row[editor]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('单选')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::radios('row[radio]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('复选')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::checkboxs('row[checkbox]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('下拉列表')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::select('row[select]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('下拉列表(多选)')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::selects('row[select]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('下拉列表(友好)')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::selectpicker('row[selectpicker]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('下拉列表(友好)(多选)')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::selectpickers('row[selectpickers]', ['aa'=>'AA', 'bb'=>'BB'], 'aa', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('动态下拉列表')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::selectpage('row[select]', 2, 'category/selectpage', null, null, ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('动态下拉列表(多选)')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::selectpages('row[select]', 2, 'category/selectpage', null, null, ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('城市选择框')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::citypicker('row[citypicker]', 2, ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('日期')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::datepicker('row[datepicker]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('时间')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::timepicker('row[timepicker]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('日期时间')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::datetimepicker('row[timepicker]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('日期区间')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::daterange('row[daterange]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('时间区间')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::timerange('row[timerange]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('日期时间区间')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::datetimerange('row[datetimerange]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('动态字段列表')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::fieldlist('row[fieldlist]', ['aa'=>'AA', 'bb'=>'BB'], null, '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('单图')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::image('row[image]', '/uploads/2018/20180629/b83227ea668e7b2d61def9812bbce3da.png', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('多图')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::images('row[images]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('单文件')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::upload('row[upload]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('多文件')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::uploads('row[uploads]', '', ['data-rule'=>'required'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('开关')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::switcher('row[switcher1]', '0', ['color'=>'success'])}
            {:Form::switcher('row[switcher2]', '1', ['color'=>'yellow', 'disabled'=>true])}
            {:Form::switcher('row[switcher3]', 'Y', ['color'=>'navy', 'yes'=>'Y', 'no'=>'N'])}
            {:Form::switcher('row[switcher4]', '1', ['color'=>'info'])}
            {:Form::switcher('row[switcher4]', '1', ['color'=>'danger', 'disabled'])}
        </div>
    </div>
 
    <div class="form-group">
        <label class="control-label col-xs-12 col-sm-2">{:__('联动选择')}:</label>
        <div class="col-xs-12 col-sm-8">
            {:Form::cxselect('ajax/area', ['province','city'], ['province'=>37, 'city'=>38])}
        </div>
    </div>
 
    <div class="form-group layer-footer">
        <label class="control-label col-xs-12 col-sm-2"></label>
        <div class="col-xs-12 col-sm-8">
            <button type="submit" class="btn btn-success btn-embossed disabled">{:__('Submit')}</button>
            <button type="reset" class="btn btn-default btn-embossed">{:__('Reset')}</button>
        </div>
    </div>
</form>

 摘自:http://tad.mucaotree.com/archives/fastadmin-shi-tu-zu-jian


posted @ 2023-06-06 12:06  温柔的风  阅读(369)  评论(0编辑  收藏  举报