mercredi 21 décembre 2016

laravel checkbox not showing

Not sure what I'm doing wrong here, could be something simple.

Code:

<section class="content">
<h1>
    Create company
</h1>
<form method = 'get' action = '{!!url("company")!!}'>
    <button class = 'btn btn-danger'>company Index</button>
</form>
<br>
<form method = 'POST' action = '{!!url("company")!!}'>
    <input type = 'hidden' name = '_token' value = ''>
    <div class="form-group">
        <label for="name">name</label>
        <input id="name" name = "name" type="text" class="form-control">
    </div>
    <div class="form-check">
        <label for="active">active</label>
        <input id="active" name = "active" type="checkbox" class="form-check-input">
    </div>
    <button class = 'btn btn-primary' type ='submit'>Create</button>
</form>

The form displays correctly, but when the form is submitted, the value of the checkbox is "on" resulting in the following sql error:

SQLSTATE[22007]: Invalid datetime format: 1366 Incorrect integer value: 'on' for column 'active' at row 1 (SQL: insert into companies (name, active, updated_at, created_at) values (Test, on, 2016-12-22 00:42:52, 2016-12-22 00:42:52))

Where do I specify which values are used for the checkbox?

Instead of 'on' or 'of' I would like 0 or 1.




Aucun commentaire:

Enregistrer un commentaire