简体   繁体   中英

Yii - Include field from another model

my question consists of two parts:

1, I'm developing small ticketing software for technical support. I have model and views for Workorder (type of ticket). I would like to include another model's field/input into this model. This model is called WorkorderJournalUpdate . It's basicly just table with 3 rows: *id, workorder_id, text* . In this case, "workorder_id" is in HAS_MANY relation with " workorder_id " in Workorder model/table .

The reason why I want to include this field/model is to create unique journal record after each Workorder update, so it looks like this:

http://luzer.eu/pu_files/27844_RelationsTC.jpg

//Edit: It would be great, if I could add new journal entry on each page update and as well read all previous records.

2, this part of my question is simple. I would like to make rule in model to make certain fields required, but only if other field is filled in. For example:

Order ID:
Ordered by:

If Order ID is not filled in, Ordered by should not be required. If Ordered by is filled in and Order ID is not, Order ID should be required . Is this possible with " required on" rule ?

This is all, hopefully, somebody will be able to help me. Thank you in advance!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM