1

I'm working on a custom module that will return a single question at a time from an existing webform. For example, from the path mymodule/(webform_nid)/(question).

This is my first encounter with cid.

From the documentation on webform_components_form(), it appears that cid represents a component id. (Elsewhere in the Drupal API documentation and on forums, I have seen it referred to as comment id).

Quickly analyzing some test data, it appears that, as a child element of a webform nid, I can reliably use it to sequentially retrieve single questions from a given webform nid.

Am I correct that cids are unique and sequential per nid? I assume the implementation of cid was done to maintain variable name convention.

Or is a cid a unique value assigned to each 'component' across the entire site, as its implementation as comment id would suggest (because you can load an existing comment without loading its node, it would need to be a globally-unique value like nid)?

3

A quick look at the webform_component table in the database, the description for that field is: "The identifier for this component within this node, starts at 0 for each node."

In my test, however, the first component has a cid of 1. AND - keep in mind that if you delete a component, the next cid is incremental - so you can't assume 1 - 6 or whatever.

| improve this answer | |
  • I didn't think to check the table comments; they do tend to be decent in Drupal modules. A subtle assumption I made is that component refers only to questions (and not to other things on the webform node). – msanford Sep 13 '12 at 18:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.