Yii Framework Forum: How to add new property to model yii framework? - Yii Framework Forum

Jump to content

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

How to add new property to model yii framework? How to add new property to model yii framework? Rate Topic: -----

#1 User is offline   Sanjay Rathod 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 17-September 16

Posted 21 October 2016 - 08:26 AM

I have added a new column in my table 'delivery_state'

And for using it in yii framework.

i have added this 'delivery_state' in model like this in following function

public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('buyer_id, seller_id, lta_product_id, currency_id, order_date, delivery_date, payment_date', 'required'),
            array('seller_id, currency_id', 'numerical', 'integerOnly'=>true),
            array('buyer_id, lta_product_id, quantity', 'length', 'max'=>11),
            array('unitary_price, total_price', 'length', 'max'=>10),
            array('delivery_title, delivery_address,delivery_state, delivery_city, delivery_country_id', 'length', 'max'=>255),
            array('delivery_zip', 'length', 'max'=>16),
            array('phone_number', 'length', 'max'=>24),
            array('notes', 'length', 'max'=>1024),
            array('status', 'length', 'max'=>1),
            // The following rule is used by search().
            // Please remove those attributes that should not be searched.
            array('id, buyer_id, seller_id, lta_product_id, quantity, unitary_price, total_price, currency_id, order_date, delivery_date, payment_date, delivery_title, delivery_address,delivery_city, delivery_zip, delivery_country_id, phone_number, notes, status', 'safe', 'on'=>'search'),
        );
    }
public function attributeLabels()
    {
        return array(
            'id' => 'Id',
            'buyer_id' => 'Buyer',
            'seller_id' => 'Seller',
            'lta_product_id' => 'Lta Product',
            'lta_contract_id' => 'Lta Contract',
            'quantity' => 'Quantity',
            'unitary_price' => 'Unitary Price',
            'total_price' => 'Total Price',
            'currency_id' => 'Currency',
            'order_date' => 'Order Date',
            'delivery_date' => 'Delivery Date',
            'payment_date' => 'Payment Date',
            'delivery_title' => 'Delivery Title',
            'delivery_address' => 'Delivery Address',
            'delivery_state' => 'Delivery State',
            'delivery_city' => 'Delivery City',
            'delivery_zip' => 'Delivery Zip',
            'delivery_country_id' => 'Delivery Country',
            'phone_number' => 'Phone Number',
            'notes' => 'Notes',
            'status' => 'Status',
            'buyer_quota' => 'Buyer Quota',
            'seller_quota' => 'Seller Quota',
        );
    }

I have added this 'delivery_state' in both the function rules and attributes but i got error message property delivery_state is not defined.

Can you guys please suggest me where i am wrong....

Or anything i am missing to define..

Thanks
0

#2 User is offline   Patrick Jones 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 495
  • Joined: 14-July 12
  • Location:Berlin

Posted 21 October 2016 - 08:57 AM

Is your database schema being cached?
Freelance developer for hire - send me a message!
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