Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

KalimeroMK's avatar

Radio button not passing value

Hi I m usiing this html template for booking selection https://codepen.io/creativetim/pen/EgVBXa

and my code is

 @foreach($roomType as $roomTypes)
                                                <div class="col-sm-3">
                                                    <div class="choice" data-toggle="wizard-radio" rel="tooltip">
                                                        <input type="radio" name="room_type_id"
                                                               value="{{ $roomTypes->id }}">
                                                        <div class="icon">
                                                            <i class="material-icons">weekend</i>
                                                        </div>
                                                        <h6>{{ $roomTypes->name }}</h6>
                                                    </div>
                                                </div>
                                            @endforeach

on dd () no value is present

array:8 [▼
  "_token" => "HGNCTXiH9eTF1JpRkvP2NHKdAF7ECGjJs76EADxp"
  "email" => "[email protected]"
  "name" => "Zoran"
  "country" => "Andorra"
  "last_name" => "Bogoevski"
  "start_date" => "2020-08-22"
  "end_date" => "2020-08-23"
  "submit" => "Зачувај"
]

bbut if I remove <div class="choice" data-toggle="wizard-radio" rel="tooltip"> it works

0 likes
7 replies
bobbybouwmann's avatar

That is because of the data-toggle. It seems to override the primary click function of the element. In that case, the input is also never clicked.

You should probably add some javascript that sets the correct radio button based on the click of a class to make this work.

Also, note that the script you're using is 4 years old and not maintained anymore. You might have a new bootstrap and jQuery version and therefore this breaks: https://github.com/VinceG/twitter-bootstrap-wizard

KalimeroMK's avatar

it is not my choice to make I mast use it and this the js code of the data-toggle

 $('[data-toggle="wizard-radio"]').click(function () {
        wizard = $(this).closest('.wizard-card');
        wizard.find('[data-toggle="wizard-radio"]').removeClass('active');
        $(this).addClass('active');
        $(wizard).find('[type="radio"]').removeAttr('checked');
        $(this).find('[type="radio"]').attr('checked', 'true');
    });

    $('[data-toggle="wizard-checkbox"]').click(function () {
        if ($(this).hasClass('active')) {
            $(this).removeClass('active');
            $(this).find('[type="checkbox"]').removeAttr('checked');
        } else {
            $(this).addClass('active');
            $(this).find('[type="checkbox"]').attr('checked', 'true');
        }
    });
Snapey's avatar

Are you sure that your radio button is part of the form?

Snapey's avatar

With the form loaded in the browser, and the browser console open, what do you get if you type

$('[data-toggle="wizard-radio"]')
KalimeroMK's avatar
n.fn.init [div.choice.active, prevObject: n.fn.init(1), context: document, selector: "[data-toggle="wizard-radio"]"]0: div.choice.activecontext: documentlength: 1prevObject: n.fn.init [document, context: document]selector: "[data-toggle="wizard-radio"]"__proto__: Object(0)

Please or to participate in this conversation.