[英]Yii - Include field from another model
my question consists of two parts: 我的问题包括两部分:
1, I'm developing small ticketing software for technical support. 1,我正在开发小型票务软件以获得技术支持。 I have model and views for Workorder (type of ticket).
我有工作订单 (凭单类型)的模型和视图。 I would like to include another
model's
field/input
into this model. 我想将另一个
model's
field/input
到该模型中。 This model
is called WorkorderJournalUpdate
. 该
model
称为WorkorderJournalUpdate
。 It's basicly just table with 3 rows:
*id, workorder_id, text*
. 它基本上只是具有
3 rows:
表3 rows:
*id, workorder_id, text*
。 In this case, "workorder_id"
is in HAS_MANY
relation with " workorder_id
" in Workorder model/table
. 在这种情况下,
"workorder_id"
是HAS_MANY
与“的关系workorder_id
在” 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: 我之所以要包含此
field/model
是为了在每次工作单更新后创建唯一的日记记录,因此它看起来像这样:
http://luzer.eu/pu_files/27844_RelationsTC.jpg 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. 2,我的问题的这一部分很简单。 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. 如果未填写
Order ID
则不需要“订购者”。 If Ordered by is filled in and Order ID
is not, Order ID
should be required
. 如果填充有序和
Order ID
不是, Order ID
应该required
。 Is this possible with " required
on" rule
? 使用“
required
on” rule
吗?
This is all, hopefully, somebody will be able to help me. 希望所有这些都可以帮助我。 Thank you in advance!
先感谢您!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.