Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190393
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:30:17+00:00 2026-05-28T19:30:17+00:00

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

  • 0

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',**

What do I write in the type field besides text and image. I will like to mention again that the radio box needs to take the user input when the node is rendered not in edit mode.

2) I tried using drupal_get_forms and I am able to attach a form and its elements to the node using drupal_get_forms but my node has many images(fields) and I need a form element for each image so its not practical to use it this way. Below is my code:

function simplequiz_node_view($node, $view_mode, $langcode)
{  
$f = drupal_get_form('simplequiz_form', $node);
$f['#weight'] = 100;
$node->content['data_collection_form'] = $f;
}

This works fine but how can I do this for say 10 image fields ? It seems the first option is better but I can’t seem to get the right field type.

// I managed to solve it as my logic was wrong I need to work with the formater and not the fields in drupal.

function simplequiz_field_formatter_info() {
return array(

'simplequiz_example_field' => array(
  'label' => t('radio button on node'),
  'field types' => array('text'),
),
 'simplequiz_btn_field' => array(
  'label' => t('button on node'),
  'field types' => array('text'),
), 

);


}

/**
* Implements hook_field_formatter_view().
*/


function simplequiz_field_formatter_view($object_type, $object, $field, $instance,    
$langcode, $items, $display) {
switch ($display['type']) {
 case 'simplequiz_example_field':
  $element[0]['#type'] = 'markup';
  $element[0]['#markup'] = theme('simplequiz_example_field', array('value' => $items[0]   
['safe_value']));
  break;

case 'simplequiz_btn_field':
  $element[0]['#type'] = 'markup';
  $element[0]['#markup'] = theme('simplequiz_btn_field', array('value' => $items[0]  
['safe_value']));
  break;
 }
 return $element;
 }

/**
* Theme the example field.
 */
function theme_simplequiz_example_field($variables) {
return '<form><input type="radio" name="type" value="silver">Gold'
.$variables['value']. ' </br> <input type="radio" name="type" value="Gold"> Silver </br>   
</form>'

    ;
}

function theme_simplequiz_btn_field($variables) {
 return '<input type="submit" class="form-submit" value="Submit" name="op" id="edit-   
submit--2">'

    ;
}

Cheers,
Vishal

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:30:18+00:00Added an answer on May 28, 2026 at 7:30 pm

    // I managed to solve it as my logic was wrong I need to work with the formater and not the fields in drupal.

    function simplequiz_field_formatter_info() {
    return array(
    
    'simplequiz_example_field' => array(
      'label' => t('radio button on node'),
      'field types' => array('text'),
    ),
     'simplequiz_btn_field' => array(
      'label' => t('button on node'),
      'field types' => array('text'),
    ), 
    
    );
    
    
    }
    
    /**
    * Implements hook_field_formatter_view().
    */
    
    
    function simplequiz_field_formatter_view($object_type, $object, $field, $instance,    
    $langcode, $items, $display) {
    switch ($display['type']) {
     case 'simplequiz_example_field':
      $element[0]['#type'] = 'markup';
      $element[0]['#markup'] = theme('simplequiz_example_field', array('value' => $items[0]   
    ['safe_value']));
      break;
    
    case 'simplequiz_btn_field':
      $element[0]['#type'] = 'markup';
      $element[0]['#markup'] = theme('simplequiz_btn_field', array('value' => $items[0]  
    ['safe_value']));
      break;
     }
     return $element;
     }
    
    /**
    * Theme the example field.
     */
    function theme_simplequiz_example_field($variables) {
    return '<form><input type="radio" name="type" value="silver">Gold'
    .$variables['value']. ' </br> <input type="radio" name="type" value="Gold"> Silver </br>   
    </form>'
    
        ;
    }
    
    function theme_simplequiz_btn_field($variables) {
     return '<input type="submit" class="form-submit" value="Submit" name="op" id="edit-   
    submit--2">'
    
        ;
    }
    

    Cheers,
    Vishal

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a Car content type with taxonomy vocabularies and CCK fields to
I have my own custom Content Provider that loads a database which contains the
I have my own asp.net cookie created like this: var authTicket = new FormsAuthenticationTicket(
I have my own type: CREATE TYPE MyType AS TABLE ( foo INT )
I have been trying to create a new content type for Plone based on
I have a site where students can post their own content on it. Whenever
Does PHP have a function that returns a file extension given a content type?
We have a requirement for a dexterity content type to have exclude from navigation
I have a PHP script which I want to output some text which I'm
I have a content type that references multiple nodes, and I need a way

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.