Skip to content

Kartik DateControl Does not work with TabularInput Widget #337

@IvandaNothabeer

Description

@IvandaNothabeer

see #215
Symptoms are the same. ( The Hidden field behind date control does not have an index number included in the field name ) Either the problem is back or it didn't really go away.


Possible temporary workaround is to add a hidden column to the TabularInput widget configuration which substitutes for the incorrectly named fields ...

					[
						'name'  => 'date',
						'title' => 'Date',
						'type'  => DateControl::className(),
						'options' => [
							'type' => DateControl::FORMAT_DATE,
							'pluginOptions' => [
								'todayHighlight' => true,
							],
			                'widgetOptions' => [
								'type' => DatePicker::TYPE_COMPONENT_PREPEND,
							],
						]
					],
                                       // Add Extra Hidden field to substitute for missing Date {multiple_index} 
					[
						'name' => 'date',
						'type' =>  \unclead\multipleinput\MultipleInputColumn::TYPE_HIDDEN_INPUT,
					],

Note however that the returned POST data will contain an extra "date" field ( containing a single date from the last row ) after the data[] array. This can be be removed in your controller code before updating the records.


			$data = Yii::$app->request->post('Transaction', []);
			$models = [];
			foreach (array_keys($data) as $index) {
				$models[$index] = new app\models\Transaction();
			}
			if (Model::loadMultiple($models, Yii::$app->request->post())) {
				unset($models['date']);
				if ( Model::validateMultiple($models)) {
					foreach ($models as $model) {
						$model->save(false);
					}
				}

[ Also want to say this is an awesome widget. Thanks to original author for all the hard work]

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions