drupal CCK:如何添加一个文本字段,其值取决于同一页面上的其他CCK字段?
我面临这种情况,我有几个 CCK 字段,并且我希望自动配置其中一个字段,具体取决于一个/某些其他字段。
例如:假设我有以下字段:
字段1:[选择列表]
字段2:[日期选择器]
字段 3:[根据字段 2 的选择自动生成值]
因此,我的意图是,根据用户在 Field2 中选择日期的方式,我将自动生成并在 Field3 中显示一些值。
我猜 Field3 并不需要是 CCK 字段,因为它实际上根本不收集用户的任何信息。我真正想要的是这种“实时反馈”,用户可以看到在 CCK 字段中输入内容时会发生什么。
有什么想法吗?谢谢。
I'm facing this situation, where I have several CCK fields, and I want one of these fields to be auto configured depends on one/some of the other fields.
For example: suppose I have the following fields:
Field1: [selection list]
Field2: [Date Picker]
Filed3: [Auto generated value depending on the selection of Field 2]
So my intent here is that depending on how the user picks the dates in Field2, I'll automatically generate and show some value in Field3.
I guess Field3 doesn't really need to be a CCK field, as it's actually not collecting any information from the user at all. What I really want is this "real-time feedback" where users can see what happens if they input something in the CCK fields.
Any idea?Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
据我所知,除了 计算字段 之外,没有办法将业务逻辑分配给 CCK 字段德鲁帕尔。
如果您希望这样的业务逻辑来控制您的字段,那么我建议以下两个选项之一:
也就是说,就我个人而言,最常选择最后一个;无论如何,当我为网站开发自定义内容时,我几乎不需要配置 GUI 以及所有选项和灵活性,那么为什么要费心开发它呢?
一个很好的例子是 CCK 字段可以是单个和多个:您的架构及其代码需要覆盖这两个字段,否则东西就会损坏。即使您确信某个领域永远不需要多样性,您仍然会花费数小时来开发它。
As far as I know, other then the computed field there is no way to assign business logic to CCK fields in Drupal.
If you want such business logic to control your fields, then I suggest either one of two options:
That said, I, personally, most often choose the last; I hardly ever need the configuration-guis and all the options and flexibility, when I am developing custom stuff for sites anyway, so why bother developing it?
A good example is the fact CCK fields can be singular and multiple: your architecture and its code will need to cover both, else stuff will break. Even if you know for sure you will never need multiplicity in a field, you'll still be spending hours developing it.