是否有一种CCK字段具有两个输入值的方法？例如，一个名为"钠" 和两个值的字段，"190mg" 和'8％' - 首先是金额，第二是每日值的％。
我正在寻找的最佳解决方案将是FieldGroups的组，每行都有3个输入。标签|价值（必填）|价值（可选） - 所以，钠| 190毫克| 8％
Is there a way to have a CCK Field have two values for one input?
For example, a field called 'Sodium' and two values, '190mg' and '8%'- first being the amount, second being % of daily value.
If not, whats the best way to achieve this?
The best solution I am looking for would be sets of Fieldgroups, and each row having 3 inputs. Label | value (required) | value (optional) - so, Sodium | 190mg | 8%
Take a look at the CCK multi group options, which are only a part of CCK 3.0+. This functionality allows you to combine multiple base fields into one field grouping. See http://drupal.org/node/119102 for the long history on how this came about.
I actually can't find good documentation on using it, as CCK 3.0 is still only in Alpha, so unfortunately you'll just have to play around with it some.
The other option is to write your own CCK field type, in which there is no issue creating multiple inputs for one field. The upshot is that you can definitely achieve this using your own custom field, the downsides are you are writing custom code (which is nice to avoid) and it's not as flexible as the multigroup options built into CCK 3.0
So you want to combine two cck fields in one, in a way?
You could use two seperate fields 'sodium mg' & 'sodium %' - and add a computed field, so you can combine the values of those two fields into one field, 'sodium values' for example.
Some more info about the Computed Field module to make such computed field possible (from its project page):
Computed Field is a very powerful field module that lets you add a custom "computed fields" to your content types. These computed fields are populated with values that you define via PHP code. You may draw on anything available to Drupal, including other fields, the current user, database tables, you name it. (Feeling the power yet? :) ) You can also choose whether to store your computed field values in the database with other content fields, or have them "calculated" on the fly during node views. (Although you should note that Views use requires database stored values.) This field is literally the Swiss Army knife of fields. So start cooking up your PHP based values!
I might be missing something but the easiest thing would be to enter the whole string "Sodium | 190mg | 8%" into the text field and then parse out the values at the theme level to do whatever you need to do - putting it in table, making a graph, etc. Underneath the text field put an example, problem solved. No alpha required.
The module that allows you to achieve this in Drupal 6 is called Multigroup, and it is part of CCK 3.x, which has an alpha release. This module allows you to add multiple fields to a fieldset, and then presents the fieldset in the familiar 'add another' manner that CCK uses for multi-value fields.
You can add all the data you want to a single CCK field, but you need a CCK type that supports this.
With CCK you can specify, how the data store should be (field_settings), how the form for inputting should be (widget) and how the field should be renderen (formatters).
You're not quite clear on how you want things, but the easiest thing to do, would be to create a have a single input/storage, and use a custom formatter to display the single value as two, based on some regex or similar.
You could also make your widget, that would create a custom form for the field and how the data should be stored. If multiple values is setup for the field, you could use
delta to separate the values. This requires more in depth knowledge of the inner workings of CCK, but would give you better data control.
The documentation on doing all of this is very limited, but looking at other modules will give you an idea on how to do it.