Hi.
I do not know what is the buzz word for the following problem.
For example:
I have a model class, which has a ‘gender’ property. This ‘gender’ property values are integer 1 and 2 (or 3).
/**
* This is the model class for table "{{example_model}}"
* @property integer $gender
*/
class ExampleModel extends ActiveRecord
{
}
I have another class, it is called for instance: ‘ModelHelper’ which has a static function to map the ‘gender’ property value to labels in the View file.:
<?php
class ModelHelper
{
public static getGenderList()
{
return [1 => Yii::t('app', 'Male'), 2 => Yii:t('app', 'Female'), 3 => Yii:t('app', 'Other')];
}
}
This is used only in the View file for a ‘Dropdown list’:
<?= $form->field($model, 'gender')->dropDownList(ModelHelper::getGenderList(), ['prompt' => Yii::t('app', 'SelectGender')]) ?>
What is your suggestions, where should I place this ModelHelper class?
I do not want to extend the original Model class, because in my view this is other kind of logic, which should be store in a seperated class.
I can place into the ‘components’, but there are behaviours, object, components classes too…