รวม form field
<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use dosamigos\fileupload\FileUpload;
use dosamigos\fileupload\FileUploadUI;
use trntv\yii\datetime\DateTimeWidget;
use common\models\NotificationType;
use yii\helpers\ArrayHelper;
?>
<div class="passenger-form">
<?php $form = ActiveForm::begin(['id'=>"form_post",'options'=>['enctype'=>'multipart/form-data']]); ?>
//text input form field
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
//text area form field
<?= $form->field($model, 'description')->textarea(['rows' => 6]) ?>
//dropdown model list formfield
<?=$form->field($model, 'notification_type_id')->dropDownList(ArrayHelper::map(NotificationType::find()->where(['status'=>1])->all(), 'id', 'name'),['prompt'=>"เลือก"])->label("ประเภทการแจ้งเตือน")?>
//date time widget form field
<?php echo $form->field($model, 'notify_date')->widget('trntv\yii\datetime\DateTimeWidget', ['phpDatetimeFormat' => 'yyyy-MM-dd', 'options' => ['class' => 'type-1-input form-control'],'clientOptions' => [
'minDate' => new \yii\web\JsExpression('new Date("2015-01-01")'), 'allowInputToggle' => false,'sideBySide' => true,'locale' => 'th','widgetPositioning' => [ 'horizontal' => 'auto', 'vertical' => 'auto'] ]] ); ?>
//dropdown array list form field
<? $notify_type =. [["id"=>"1","name"=>"กำหนด [วันที่-เดือน-ปี]"],
["id"=>"2","name"=>"กำหนด [วันจันทร์-อาทิตย์ รายสัปดาห์]"],
["id"=>"3","name"=>"กำหนด [วันที่ รายเดือน]"],
["id"=>"4","name"=>"กำหนด [วันที่-เดือน รายปี]"] ]?>
<?=$form->field($model, 'notify_type')->dropDownList(ArrayHelper::map($notify_type, 'id', 'name'),['prompt'=>"เลือก",'id'=>"notify-type-dropdown"])->label("ประเภทการแจ้งเตือน")?>
//dropdown day form field
<?
$day=["อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์"];
$day_type =[];
for($i=0;$i<=6;$i++){
$day_type []=["id"=>$i,"name"=>$day[$i]];
}
?>
<?=$form->field($model, 'day_type')->dropDownList(ArrayHelper::map($day_type, 'id', 'name'),['prompt'=>"เลือก",'class'=>"type-2-dropdown"])->label("วันในสัปดาห์")?>
//dropdown months form field
<?
$month = [ "มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม" ];
$months =[];
for($i=1;$i<=12;$i++){
$months []=["id"=>$i,"name"=>$month[$i-1]];
}?>
<?=$form->field($model, 'month')->dropDownList(ArrayHelper::map($months, 'id', 'name'),['prompt'=>"เลือก",'class'=>"type-4-dropdown"])->label("เดือน")?>
//cropper image form field
<?if($model->image_path != null){
$model->image_path =Yii::getAlias("@ImagePath/uploads/van-go/passenger/") . $model->image_path ;
}?>
<?echo $form->field($model, 'image_path')->widget(\coldlook\cropper\Cropper::className(), [
'label' => 'อัพโหลดรูปภาพ',
'imageUrl' => $model->image_path,
'cropperOptions' => [
'width' => 256,
'height' => 256,
'preview' => [
'width' => 200,
'height' => 200,
],
],
'uploadOptions'=>[
'url'=>'/benz_room072/passenger/upload_image?id='.$model->id,
'delete_url'=>'/benz_room072/passenger/delete_image?id='.$model->id,
'response'=>'res.result.url'
]
])->label(false); ?>
<div class="hidden">
//upload multiple image form field
<?if($model->map_path != null){
$model->map_path =Yii::getAlias("@ImagePath/uploads/van-go/map/") . $model->map_path ;
}?>
<?echo $form->field($model, 'image_path')->widget(\bnz\attachimage\UIAttachImage::className(), [
'label'=>"แนบไฟล์ภาพ",
'uploadOptions'=>[
'upload_url'=>Yii::getAlias('@frontend_url/design-job/attach-image-upload') ,
'load_url'=>Yii::getAlias('@frontend_url/design-job/load-attach-image?id=').$model->id
]
])->label(false) ?>
</div>
//cropper image form field
<?echo $form->field($model, 'map_path')->widget(\coldlook\cropper\Cropper::className(), [
'label' => 'อัพโหลดแผนที่',
'imageUrl' => $model->map_path,
'cropperOptions' => [
'width' => 1600,
'height' => 900,
'preview' => [
'width' => 640,
'height' => 360,
],
],
'uploadOptions'=>[
'url'=>'/benz_room072/passenger/upload_map?id='.$model->id,
'delete_url'=>'/benz_room072/passenger/delete_map?id='.$model->id,
'response'=>'res.result.url'
]
])->label(false); ?>
//upload multiple file form field
<?echo $form->field($model, 'map_vdo_path')->widget(\bnz\attachfile\UIAttachFile::className(), [
'label'=>"แนบไฟล์",
'uploadOptions'=>[
'upload_url'=>Yii::getAlias('@frontend_url/passenger/attach-vdo-upload') ,
'load_url'=>Yii::getAlias('@frontend_url/passenger/load-attach-vdo?id=').$model->id
]
])->label(false) ?>
// status form field
<? $status = [["id"=>"1","name"=>"แสดง"],["id"=>"0","name"=>"ไม่แสดง"]]?>
<?=$form->field($model, 'status')->dropDownList(ArrayHelper::map($status, 'id', 'name'))->label("สถานะ")?>
<div class="form-group">
<button id= "submit_button" type="button" class='btn btn-success'><?print Yii::t('frontend', 'Save');?>
</button>
</div>
<?php ActiveForm::end(); ?>
</div>
ตรวจสอบการ import Library หรือ extension อีกที