Change Values Radio Buttons

Hi Stephanie,

Just installed version 1.6.3, and based on the new features (http://formidablepro.com/formidable-v1-6-3/) I thought we could also define the values of each Radio Button individually, only i don’t see that option.

However, I found the code below which chances that value based on the field ID. Is it also possible to use the field KEY? I tried replacing id with use_key, but that doesn’t seem to work.

add_filter('frm_setup_new_fields_vars', 'show_user_dropdown', 15, 2);
add_filter('frm_setup_edit_fields_vars', 'show_user_dropdown', 15, 3);
function show_user_dropdown($values, $field, $entry_id=false){
  if($field->id == 125 ){ //change 125 to the ID of your field
       $values['options'] = array(1 => 'Option 1 text', 2 => 'Option 2 text', 'value' => 'Option text');
       $values['use_key'] = true;
  }
return $values;
}

Thnx :) 

To use separate labels, first check the box in the field options to "use separate vales". You can find a screenshot in the blog post:
http://formidablepro.com/formidable-v1-6-3/

Let us know if you still have questions.

Hi Stephanie,

Thnx for the fast feedback. As yo can see on the attached screenshot, I don't have that option. I checked my version and I do have 1.6.3 installed. Any idea what this can be ?

 

Thnx


Attachment:
no-field-values

That's a scale field. The option isn't available in that field type. You'll need to use a radio, dropdown, or checkbox field to use separate values.

Ok, that explains why. But is it possible to use the code I posted in my opening post and have it select on field KEY instead of field ID? This way I can replace the value of the radio buttons.

Are you referring to the if($field->id ==25) line? Can you please clarify?

Every field contains a box "FIELD KEY".  As you can see in the above picture, I named that field "ster1". I use several forms with the same scale field setup, where I want to change the values of each radio button. With the above code I can changes the values of the scale radio button based on the FIELD ID.

However, if I want to assign the above code to all the fields that use an ID, the list will be very long. That is why I want to use the FIELD KEY as an identifier.

i tried to use:

if($field->key ==ster1)

but this doesn't seem to work. Hope this explains it.

You'd need to use $field->field_key. However, field keys are also unique, so you'd need something like
If(strpos($field->field_key, 'ster') !== false)

This would apply your code to any field that includes ster in the field key.

That works amazing :) Thnx for clearing that up. I thought Field Key's weren't unique.

Topic closed.