yii中的form表单的写法

<?php
/**
 * Created by PhpStorm.
 * User: Hansn cz P03
 * Date: 17/11/17
 * Time: 9:56
 */
use yii\helpers\Url;
use yii\widgets\ActiveForm;
use common\components\Leohowl;
use backend\components\AddChip\AddChipWidget;
$model['uuid'] = isset($model['uuid']) ? $model['uuid'] : Leohowl::createRandomString(6);
$model['status'] = isset($model['status']) ? $model['status'] : 1;
$model['orders'] = isset($model['orders']) ? $model['orders'] : 100;
$model['author'] = isset($model['author']) ? $model['author'] : 'yhj';
$model['publish_time'] = $model['publish_time'] ? Date('Y-m-d',$model['publish_time']) : Date('Y-m-d',time());

if($type === 'add'){
  $template = [
    'action' => '添加',
    'url' => Url::toRoute(['/cb/add'])
  ];
} else {
  $template = [
    'action' => '更新',
    'url' => Url::toRoute(['/cb/edit', 'uuid'=>$model['uuid']])
  ];
}

$this->title = "CB系列";
$this->params['breadcrumbs'][] = ['label'=>'产品中心'];
$this->params['breadcrumbs'][] = ['label'=>'CB列表', 'url'=>Url::toRoute(['/cb/list'])];
$this->params['breadcrumbs'][] = ['label'=>$template['action'].'产品详情'];
$this->params['page_title'] = $template['action'].'产品详情';

$this->registerJsFile(DIST . '/script/flatpickr.min.js', ['depends' => backend\assets\AppAsset::className(), "position"=> $this::POS_END]);
$this->registerCssFile(DIST . '/style/flatpickr.min.css', ['depends' => backend\assets\AppAsset::className(), "position"=> $this::POS_END]);

?>
<div class="box box-solid">
  <div class="box-body">
    <?php
    $form = ActiveForm::begin([
      'id'=>'cms-culture',
      'action'=>$template['url'],
      'method'=>'post',
      'fieldConfig'=>[
        'template'=>'<div class="form-group input-group"><div class="col-lg-3">{label}</div><div class="col-lg-7">{input}</div></div>',
        'inputOptions' => ['class' => 'form-control'],
      ],
    ])
    ?>
    <div class="col-lg-12">
      <?=
      $form

        ->field($model, 'uuid',['template'=>'{input}'])
        ->textInput(['maxlength' => 16,'type'=>'text'])
        ->hiddenInput()
        ->label(false)
      ?>
      <?=
      $form
        ->field($model, 'title')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>产品型号',['class'=>'input-group-addon'])
      ?>
      <?=
      $form
        ->field($model, 'cb_style')
        ->radioList(['1'=>'CB-A', '0'=>'CB-B'])
        ->label('<span class="required">*</span>CB分类',['class'=>'input-group-addon'])
      ?>
      <?=
      $form
        ->field($model, 'volume')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>处理风量CMH',['class'=>'input-group-addon'])
      ?>

      <?=
      $form
        ->field($model, 'resistance')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>设备阻力',['class'=>'input-group-addon'])
      ?>
      <?=
      $form
        ->field($model, 'size')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>外形尺寸(L×W×H,mm)',['class'=>'input-group-addon'])
      ?>
      <?=
      $form
        ->field($model, 'flk_size')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>法兰口尺寸(A×B,mm)',['class'=>'input-group-addon'])
      ?>

      <?=
      $form
        ->field($model, 'space')
        ->textInput(['maxlength' => 128,'type'=>'text'])
        ->label('<span class="required">*</span>维护保养作业空间(D,mm)',['class'=>'input-group-addon'])
      ?>
      <?=FilePicker::widget([
        'form' => $form,
        'model' => $model,
        'paramKey' => 'pdf',
        'proportionTotal' => 10,
        'label' => '数据下载pdf',
        'tip' => 'pdf',
        'required' => true,
        'selectLimit'=> 1
      ])?>
      <?=$form->field($model, 'author')->textInput(['maxlength' => 64,'type'=>'text'])->label('作者',['class'=>'input-group-addon'])?>
      <?=$form->field($model, 'publish_time')->textInput(['maxlength' => 64,'type'=>'text','class'=>'form-control datetimepicker', 'data-date-format'=>"Y-m-d"])->label('发布时间',['class'=>'input-group-addon'])?>
      <?=$form->field($model, 'orders')->textInput(['maxlength' => 64,'type'=>'text'])->label('排序',['class'=>'input-group-addon'])?>

      <?=
      $form
        ->field($model, 'status')
        ->radioList(['1'=>'在线', '0'=>'离线'])
        ->label('<span class="required">*</span>状态')
      ?>
    </div>
    <div class="col-lg-12 submit">
      <div class="col-lg-3"></div>
      <div class="col-lg-8"><button type="submit" class="btn btn-success push-action"><?=$template['action']?></button></div>
    </div>
    <?php  ActiveForm::end();?>
  </div>
</div>

<!--<script>-->
<?php $this->beginBlock('script') ?>

$('.datetimepicker').flatpickr();
<?php $this->endBlock() ?>
<?php $this->registerJs($this->blocks['script'], \yii\web\View::POS_END); ?>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

原克技术

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值