Would a static function in a widget be bad practice?

I’ve got a few different item types (events, vouchers, competitions done as modules) which can all have multiple dates.

To handle this I created a widget which will display all linked dates.

The widget also allows you to add and modify dates.

When the form is submitted it goes off to the modules controller.

Now a bit of formatting needs to be done to the dates input so I can’t just load and save.

My question is would putting the formatting function in the class of the widget be bad practice? Should I put it elsewhere?

i.e. Controller.php




public function actionSave($id)

{

    //...

    DatesWidget::saveData(Yii::$app->request->post());

    //...

}



Hi,

For data formatting before saving : beforeSave() in the model may be a good solution.

Jok