Input is not appearing checked

0

I have input of which according to the user's data in its session it is marked or not. The problem is that even input has property checked="checked" , it is not marked.

Code of input along with div of which it is:

<div class="no-message">
      <input type="radio" id="isgift0" name="isgift" value="0" style="display: none;" class="arredondado" <?php if(Mage::getSingleton('core/session')->getInputMensagem() == 1) echo 'checked="checked"' ?> /> 
      <label for="isgift0"><?php echo $this->__("I do not want to send a message") ?></label>
 </div>

In this label it contains a code that CSS that uses an image above input as if it were the same, but this does not interfere with anything in functionality.

Códgio CSS :

input[type="radio"].arredondado:not(checked) + label:before {
    content: "...";
    display: inline-block;
    margin-top: -2px;
    vertical-align: middle;
    margin-right: 10px;
    background: url(../../images/icons.png) no-repeat -53px -529px;
    width: 22px;
    height: 23px;
    color: transparent;
    border-radius: 0 !important;
    border: none !important;
}
    
asked by anonymous 30.11.2017 / 20:29

2 answers

0

I solved this problem by simply doing a check with jQuery , along with php in loading the page, and thus, according to the user's data in his session, assigning it through .prop() the property checked to input .

Code of script :

<script>
    $j(document).ready(function () {
    <?php 
       if(Mage::getSingleton('core/session')->getInputMensagem() == 1) {
    ?>
       $j('#isgift0').prop('checked','checked');
    <?php
       }
    ?>
    });
</script>
    
01.12.2017 / 20:38
1

It is like display none and you can switch to an if ternary like this:

<input type="radio" id="isgift0" name="isgift" value="0"
       class="arredondado" <?php echo Mage::getSingleton('core/session')->getInputMensagem() == 1 == 1 ?  'checked="checked"' : ''?> />

css:

 input[type="radio"].arredondado:not(checked) + label:before {
        content: url(icon2.png);
        display: inline-block;
        margin-top: -2px;
        vertical-align: middle;
        margin-right: 10px;
        width: 22px;
        height: 23px;
        border-radius: 0 !important;
        border: none !important;
    }
    
30.11.2017 / 20:31