0
votes

I am new to magento. I am currently using radio button with image in product page to select values. The radio button is working correctly but the value is not storing in database. My code is in the file :

app\design\frontend\rwd\default\template\catalog\product\view\options\type\default.phtml

Default.phtml :

<?php $_option = $this->getOption() ?><?php //var_dump($_option->getId());die; //print_r($_option->getValues()); ?>


    <?php
    if($option_values = $_option->getValues()){?>
    <dt>
    <label class=""><em>*</em><?php echo  $this->escapeHtml($_option->getTitle()) ?></label>

    </dt>
    <?php
    foreach($option_values as $value)
    {
    $custom_options = $value->getData();
    $id = "option ".$custom_options['option_type_id']." text";
    ?>
    <input type="radio"
    class="input-radio product-custom-option" 
    name="theme" 
    id="<?php echo $id;?>" 
    style="display:none"
    value ="3456789" 
    onClick=check("<?php echo strtolower(str_replace(" ","_",$id));?>")>
    <label 
    for="<?php echo $id;?>"
    name="options[<?php echo $id ?>]"
    id="<?php echo $id ?>"
    value="ythuj"
    >
    <img class="img_border" 
    src ='<?php echo  Mage::getBaseUrl('media').$custom_options["thum_image"]?>' 
    id ="<?php echo strtolower(str_replace(" ","_",$id));?>" 
    value = "asdf"
    >
    </label>

    <?php } ?>

    <?php }

    ?>

From pageSource:

</dt>
<input type="radio"
class="input-radio product-custom-option" 
 name="theme" 
id="option 582 text" 
style="display:none"
value ="3456789" 
onClick=check("option_582_text")>
<label 
for="option 582 text"
name="options[option 582 text]"
id="option 582 text"
value="ythuj"
 >
<img class="img_border" 
 src ='http://127.0.0.1/asd/media/catalog/customoptions/1.png' 
 id ="option_582_text" 
 value = "asdf"
  >
 </label>

How can i resolve this? The input text box are working correctly only the radio button values are missing?

1
If you post your html source of the page from the browser, It is easy to resolve this... - Thanga
@Thanga but the html code is working correctly. Anyway ill post the code? - user3041822
Yes. In browser see the view source and copy paste it - Thanga
posted it already in the question - user3041822

1 Answers

0
votes
  1. Radio boxes are submitted/identified by their name only.
  2. For a particular radio box group, the name should be same and without spaces. For e-g

<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>

In this gender is a radio box group and one of them can be selected and submitted in post/get data as gender=male or gender=female

In your case, the radio button names seem to be theme and options[option 582 text] which makes them not working as expected.

Solution is to name the radio buttons properly with same name and with single alphanumeric string.