Hi all,

I'm following this tutorial.

As it stands, the user selection is printed in the body once submitted.

I.e.
User selects and submits:
'Checkbox A'
'Checkbox B'

Checkboxes:
Checkbox A
Checkbox B

is printed in the body.

How would I modify the above code so that if, for example,:

User selects and submits checkbox A.

Checkboxes:
foo

is printed in the body.

Or, if User selects and submits checkbox B.

Checkboxes:
bar

is printed in the body.

If checkbox A and B are selected.

Checkboxes:
foo
bar

is printed in the body.

Any help would be greatly appreciated!

-int

Comments

I believe that the checkboxes

I believe that the checkboxes field will come back with an array containing the indices of the boxes that are checked.

Don't take my word for it, though. Install the Devel module. It has all sorts of wonderful ways of outputting debugging information.

As for outputting that stuff as you want...I think you might need to theme your new content type to output what you want differently.

--
www.ztwistbooks.com. Math books that are actually fun.

Thanks for the reply DanZ, So

Thanks for the reply DanZ,

So in Drupal, the logic which says:
if checkbox A selected then
Do task (in this case, add "foo" to field content)

if checkbox B selected then
Do task (in this case, add "bar" to field content)

Should be dealt with in theming?

From the theme layer documentation:

The first step is that logic must be separated as much as possible from presentation. To accomplish this, modules do as much of the work on the data as possible, and hand that data off to the presentation layer

I'm a little confused as to where I need to implement the logic which acts based on a checkbox selection...

You have the essence of it,

You have the essence of it, yes.

In Drupal, pages and everything on them are represented by complex data structures. While the page is being processed, Drupal sees the data for your checkboxes and puts those on your page.

So, to add your "foo" and "bar" to the page, you can do it two ways. You can add code which will update the data structure to contain "foo" and "bar" in an appropriate field. You can also theme the page to look at the (unmodified) data structure and output HTML displaying what you want.

I'm going to ask you to step back a bit, though. What exactly are you trying to accomplish here? Don't worry about that tutorial for the moment. There are generally easier ways to deal with different kinds of data.

--
www.ztwistbooks.com. Math books that are actually fun.