This code uses html, php and laravel. The first one 'tk' doesn't change in value whatever i do. The second one 'ntk' does change the value but eventually my output on the webpage allways gives me checked checkboxes for some reason. Really hope someone could help me out because I really don't know how this is possible. Especially that when I enter false in $ntk than the checkbox stays unchecked.
Here's my form:
<?php
$tk = Session::has('tk') ? Session::get('tk') : 1;
var_dump($tk);
if($tk == 1){
$tk = 'true';
} else {
$tk = 'false';
}
$tk_name = 'tk: ';
var_dump($tk_name);
var_dump($tk);
$ntk = Session::has('ntk') ? Session::get('ntk') : 0;
var_dump($ntk);
if($ntk == 1){
$ntk = 'true';
} else {
$ntk = 'false';
}
$ntk_name = 'ntk: ';
var_dump($ntk_name);
var_dump($ntk);
?>
{{ Form::open(array('url' => 'aanvullen')) }}
<table>
<tr>
<td>
{{ Form::submit('Toepassen') }}
</td>
<td>
{{ Form::checkbox('tk', 1, $tk) }} Tijdkritisch (TK) <br>
{{ Form::checkbox('ntk', 1, $ntk) }} Niet-tijdkritisch (NTK)
<td>
</tr>
</table>
{{ Form::close() }}
Here's my controller code:
if(isset($_POST['tk']) )
{
$tk = $_POST['tk'];
Session::put('tk', $tk);
} else {
$tk = 1;
Session::put('tk', $tk);
}
if(isset($_POST['ntk']) )
{
$ntk = $_POST['ntk'];
Session::put('ntk', $ntk);
} else {
$ntk = 0;
Session::put('ntk', $ntk);
}