-
Notifications
You must be signed in to change notification settings - Fork 127
Open
Labels
Description
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]