1

I see in the docs that we use checkbox like that:

echo Form::checkbox('name', 'value', true);

In my case, value is boolean (0 and 1) and is linked to the next param ( isChecked )

So basically, I should do

<div class="checkbox-switch">
            <label>
                <?php $old = $tournament->mustPay;
                $checked = $old ? 'checked' : '';
                ?>

                {!!  Form::label('mustPay', trans('crud.pay4register'))  !!} <br/>
                {!!   Form::checkbox('mustPay', $old, $old , ['class' => 'switch', $checked , 'data-on-text'=>"Si", 'data-off-text'=>"No", "value" => "true"]) !!}

            </label>
        </div>

It seems very difficult to manage checkbox state without having linking between value and state.

Then I try to avoid to have

I'm spending a lot of time managing it, and get patchwork instead of an elegant solution. Is there an elegant way to do it, because I couldn't find one which fit my needs.... :(

Tx

1
  • why would the value of that checkbox change ? Commented Dec 8, 2015 at 1:10

1 Answer 1

2

Im not entirely sure what you are doing, but this might help

Form::hidden('mustPay', 0);
Form::checkbox('mustPay', 1, $tournament->mustPay, ['class' => 'switch', 'data-on-text'=>"Si", 'data-off-text'=>"No"]);
Sign up to request clarification or add additional context in comments.

2 Comments

it worked! I confused the checkbox concept with Yes / No switch! Tx!
hehe, i thought it might be something like that ... all good, glad it works my friend

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.