Adding Form Elements to a node for user input in drupal 7

1 reply [Last post]
Last seen: 3 years 45 weeks ago
Joined: 2011-11-08


I have my own content type made in my module. It has text and image fields.

I now want to add a form fields like radio box and a submit button so that when the node is rendered the user can give their input. I unable to do this.

1) My first try failed when I tried adding a radio box when creating my content type.

simplequiz_radio11' => array(
'field_name' => 'simplequiz_radio11,
'type' => 'radio',

2) My second try was to use drupal_get_form which worked but I have 9 image fields in my node and I want to add 9 radio box below each one and only one submit button.

So this option does not seem the right option for me.


Chris Shattuck
Last seen: 10 weeks 4 days ago
Joined: 2009-08-16
Good question, Vishal, It

Good question, Vishal,

It sounds like you might want to use a hook_form_alter() in order to add the radios below each image field. Here's a video in how to use hook_form_alter():

You can use a debugger (21:40 - How to use a PHP debugger in Drupal) or a function like var_dump() in order to look at the contents of the form array. Then you can add your radios after each image field there.

Let me know if that helps point you in the right direction.


Add to playlist

Add to , or

Add to new playlist:

Add to playlist
This is a member-only feature
But, it's easy to become a member

Add to cart:

Contact us

Below are the supported keyboard shortcuts for our video player.

Start / stop video
Go to next video
Go to previous video
Increase or decrease player speed by 20%
Skip ahead or go back by 15 seconds
Jump to a percentage (2 is 20%, for example)
Toggle full screen
Videos Pricing More Search
BuildAModule Logo Icon BuildAModule Logo Icon
Become a member!
1 month
6 months
10% off
12 months
20% off
All memberships come with the following:
24 / 7 access to the entire 1800+ video library
An innovative video player with a rolling transcript
Extensive Drupal and cross-platform training
A thorough and thoughtful training style
Progress tracking
Take notes on specific video sections
Intuitive multi-user management
How many users?
Go solo with a single user, or give multiple team members access through one account and get discounts by bundling multiple users into a single membership.