Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kartik DateControl Does not work with TabularInput Widget #337

Open
IvandaNothabeer opened this issue Oct 11, 2020 · 1 comment
Open

Kartik DateControl Does not work with TabularInput Widget #337

IvandaNothabeer opened this issue Oct 11, 2020 · 1 comment

Comments

@IvandaNothabeer
Copy link

IvandaNothabeer commented Oct 11, 2020

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]

@unclead
Copy link
Owner

unclead commented Oct 14, 2020

@IvandaNothabeer thx for reporting an issue. according to a comment from the closed issue, the problem has been fixed. May be something changed in kartik's library and the original issue came back
Anyway somebody has to investigate it. The widget's code isn't complicated and probably this person can be you 😄
I didn't touch the widget's code and yii2 in general for a long time and TBH I'm a bit of out of context already

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants