Example #1
0
 /**
  * @param \Restyii\Model\ActiveRecord $model the model instance
  * @param string $attribute the attribute name
  *
  * @return string
  */
 public function formatAttribute($model, $attribute)
 {
     $format = $model->getAttributeFormat($attribute);
     if ($format == 'choice' && method_exists($model, $attribute . 'Labels')) {
         $methodName = $attribute . 'Labels';
         return $this->formatChoice($model->{$attribute}, $model->{$methodName}());
     }
     $methodName = 'format' . $format;
     if (method_exists($this, $methodName)) {
         return $this->{$methodName}($model->{$attribute});
     } else {
         return $this->formatText($model->{$attribute});
     }
 }