K
K
KevinSmash2019-03-27 11:54:19
Yii
KevinSmash, 2019-03-27 11:54:19

How can data be changed in GridView columns using DatePicker?

Hello, it is necessary that you can set a date in a table in a calendar format for different rows. I wrote my own code, but it only changes the first row in the column, and after refreshing the page, it resets it. Here is the code:
Model

['date_subscription', 'default', 'value' => null],
 ['date_subscription', 'date_subscription', 'timestampAttribute' => 'date_subscription'],

Search
public $date;

    public function rules()
    {
        return [
[['date_subscription'], 'safe'],
['date_subscription', 'default', 'value' => null],

...

 if ($this->date !== null) {
            $date = strtotime($this->date);
            $query->andFilterWhere(['between', 'date_subscription', $date, $date + 3600 * 24]);
        }

view
[
'label' => 'Дата подписки',
                'attribute' => 'date_subscription',
                'value' => function ($model, $key, $value) {
                    return  \yii\jui\DatePicker::widget([
                        'attribute' => 'date_subscription',
                        'model' => $model,
                         ]);
                    },
                'format' => 'raw',
                 ],

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question