310 Posts
ricco
11 years ago
Topic

Hi,

How are you?

Thank you for creating Seblod.

I'm trying to achieve something which over my knowledge.

I've created a radio field with 2 options: e.g. option 1; option 2

In a position override I'm trying to write the code to get the values of some fields if option 1 is the selected option and the values of some different fields if option 2 is the selected option.

I've found some example code in the old forum but it's not enough, here it is:

<?php
// get the checkbox values
$options = $cck->get('my_checkbox_field')->value;
// create an array of the values
$optarray = explode(",",$options);
// verify if x value is in the array, if yes display another field
if (in_array("x", $optarray)) echo $cck->renderField('another_field');
?>
I hope you understand me.

So basically I'm trying to do something like this:

if radio field is option 1 echo field1 and field2

else echo field3 and field4

Could you help please?

Thank you again

Best Regards
Rumen

Get a VIP membership
310 Posts
ricco
11 years ago
0
Level 1

Hi,

just to share how I managed to solve it in case someone needs it:

<?php
  // get the checkbox values
  $options = $cck->get('rf_price_options')->value;
  // create an array of the values
  $optarray = explode(",",$options);
  // verify if x value is in the array, if yes display another field
  if (in_array("On request", $optarray)) { ?>
  <div style="margin-right: 3px; float: left; font-size: 1em; text-align: left; font-weight: bold; color: #F35E5E; ">
  <?php echo $cck->getValue(your_field'); ?>
  </div>
  <?php } else { ?>
  <div style="margin-right: 3px; float: left; font-size: 1em; text-align: left; font-weight: bold; color: #F35E5E; ">
  <?php echo $cck->getValue('your_field'); ?>
  </div>
  <div style="float: left; font-size: 1em; text-align: left; font-weight: bold; color: #F35E5E; ">
  <?php echo $cck->getValue(your_field'); ?>
  </div>
  <div style="margin-left: 3px; float: left; font-size: 1em; text-align: left; font-weight: bold; color: #F35E5E; ">
  <?php echo $cck->getValue( 'your_field' ); ?>
  </div>
  <? } ?>

All the best

Get a Book for SEBLOD