Skip to content

Commit

Permalink
form checkbox with auto checked
Browse files Browse the repository at this point in the history
  • Loading branch information
veneliniliev committed Jan 18, 2017
1 parent ed67900 commit 9684330
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions resources/views/components/fields/checkbox.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,24 @@
$options['attr']['class'] = '';
}
$options['attr']['id'] = str_random(20);
/*
* Автоматично чекване
*/
if (!isset($options['checked']) || is_array($options['checked'])) {
//for translates
if (!empty($options['translate'])) {
if ($options['value'] === '') {
$options['checked'] = (empty($options['default_checked']) ? false : $options['default_checked']);
} elseif ($options['value'] == true) {
$options['checked'] = true;
} elseif ($options['value'] == false) {
$options['checked'] = false;
}
}
}
echo Form::checkbox($name, $options['value'], (boolean)$options['checked'], $options['attr']);
?>

Expand Down

0 comments on commit 9684330

Please sign in to comment.