Yii Framework Forum: Property getter in model doesn't work - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Property getter in model doesn't work Rate Topic: -----

#1 User is offline   Siquell 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 01-June 17

Posted 19 June 2017 - 12:22 PM

My model code:
<?php

Yii::import('application.models._base.BaseAddress');

class Address extends BaseAddress {

    public static function model($className = __CLASS__) {
        return parent::model($className);
    }

    public function rules() {
        ...
    }
    
    public function getFullAddress() {
        return $this->address_text . (empty($this->comment) ? '' : ', ' . $this->comment);
    }

}


When I use $model->startAddress->getFullAddreess() it works fine.
$model->startAddress->fullAddreess gives CException property is not defined. Changing case of method name doesn't help.
0

#2 User is offline   alrazi 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,289
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 20 June 2017 - 01:47 AM

it should work, there is typo in your code that could be a problem

// change this
$model->startAddress->fullAddreess
// to 
$model->startAddress->fullAddress

1

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users