Yii2 framework. The idea to create common behavior for common model:
- before Validate trims all fields in model.
if it's array trim all values in array.
I'm wondered why in Yii2 core doesn't exist such possibility. Or I'm wrong. Am I?
What problems could I face if I trim all fields?
You can create a behavior and attach it at your models.
1) Create the behavior
TrimBehavior
incommon/components
.2) In your models add the following:
Trimming attributes it depends on business logic. If you really need it then it's ok.