We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Using Radio buttons while making a TAB (Module EE)

Development and Programming

Stinkotter's avatar
Stinkotter
26 posts
12 years ago
Stinkotter's avatar Stinkotter

Dear Expression Engine members,

Does somebody know how I can use radio buttons as field_type with different values and keys.

This works:

function publish_tabs($channel_id, $entry_id = '')
 {

  $settings = array();
  
  $existing_files = array('0','1');
  
  
  $settings[] = array(
    'field_id'    => 'message_preview',
    'field_label'   =>  ee()->lang->line('tab_title'),
    'field_required'   => 'n',
    'field_list_items'  => $existing_files,
    'field_data'   => '0',
    'field_instructions'  => ee()->lang->line('tab_instructions'),
    'field_pre_populate' => 'n',
    'field_text_direction' => 'ltr',
    'field_type'    => 'radio',
    'module_name'    => 'Message Test'    
  );
  
   

  return $settings;
  
 }

But how can I change the name? So that the value stays 0 or 1 but the message/ name is what I want, like:

<input type="radio" name="radio" value="0"> Water

<input type="radio" name="radio" value="1"> Juice 

So that I can use my language file for the keys but not the values

I don’t think it is that difficult but I cannot find it somewhere..

Thanks in advance,

       
Bhashkar Yadav's avatar
Bhashkar Yadav
727 posts
12 years ago
Bhashkar Yadav's avatar Bhashkar Yadav

You can use Pixel and Tonic’s “Field Pack” (http://devot-ee.com/add-ons/field-pack) for this purpose. Its having radio buttons also.

       
Stinkotter's avatar
Stinkotter
26 posts
12 years ago
Stinkotter's avatar Stinkotter

But I’am making a standalone Module, so that people dont have to download that package too. Is there not an other solution?

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.