예제 #1
0

    <?php 
echo $form->field($model, 'name');
?>

    <?php 
echo $form->field($model, 'date_start')->widget(DatePicker::classname(), ['language' => 'ru', 'dateFormat' => 'dd.MM.yyyy', 'options' => ['class' => 'form-control']]);
?>

    <?php 
echo $form->field($model, 'date_end')->widget(DatePicker::classname(), ['language' => 'ru', 'dateFormat' => 'dd.MM.yyyy', 'options' => ['class' => 'form-control']]);
?>

    <?php 
echo $form->field($model, 'author_id')->dropDownList(Authors::getAuthorsList(true));
?>

    <div class="form-group">
        <?php 
echo Html::submitButton('Search', ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Reset', Yii::$app->getUrlManager()->createUrl('books/index'), ['class' => 'btn btn-default']);
?>
    </div>

    <?php 
ActiveForm::end();
?>
예제 #2
0
파일: _search.php 프로젝트: Araused/books
use kartik\date\DatePicker;
/* @var $this yii\web\View */
/* @var $model app\models\search\BooksSearch */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="books-search">

    <?php 
$form = ActiveForm::begin(['action' => ['index'], 'method' => 'get']);
?>

    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'author_id')->dropDownList(Authors::getAuthorsList(), ['prompt' => '']);
?>
        </div>
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'name');
?>
        </div>
    </div>

    <div class="row">
        <div class="col-md-6">
            <?php 
echo $form->field($model, 'dateStart')->widget(DatePicker::className(), ['language' => 'ru', 'type' => DatePicker::TYPE_INPUT, 'options' => ['class' => 'form-control'], 'pluginOptions' => ['autoclose' => true, 'format' => 'yyyy-mm-dd']]);
?>
        </div>
예제 #3
0
 /**
  * Updates an existing Books model.
  * If update is successful, the browser will be redirected to the 'view' page.
  *
  * @param integer $id
  *
  * @return mixed
  */
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     $oldFilePath = $model->preview_image;
     if ($model->load(Yii::$app->request->post())) {
         $image = $model->uploadImage();
         if ($image === false) {
             $model->preview_image = $oldFilePath;
         }
         if ($model->save()) {
             if ($image !== false) {
                 // delete old and overwrite
                 $path = $model->getImageFile();
                 $image->saveAs($path);
             }
         }
         //сохранение параметров фильтра
         $filterParams = $_GET;
         if (ArrayHelper::keyExists('id', $filterParams)) {
             unset($filterParams['id']);
             if ($filterParams) {
                 $url = ['search'] + $filterParams;
                 return $this->redirect($url);
             }
         }
         return $this->redirect(['index']);
     } else {
         return $this->render('update', ['model' => $model, 'authors' => Authors::getAuthorsList()]);
     }
 }