Skip to content

Commit

Permalink
fix foreign type
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanMeurisse committed Jul 31, 2024
1 parent f90ea01 commit 84e978e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Binary file modified src/.DS_Store
Binary file not shown.
15 changes: 8 additions & 7 deletions src/FieldTypes/Foreign.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,19 @@ class Foreign
{
public static function prepare($name, $options = [], $value = null, $properties = [])
{
// Define the total of columns
$colsSize = 12 / $properties['config']['cols'];

$html = '<div class="row i-checks">';
foreach ($options as $key => $option) {
$uniqueId = uniqid('opt', true) . md5(mt_rand(1, 1000));
$uniqueId = uniqid('opt', true).md5(mt_rand(1, 1000));
$checkbox = Html::checkbox($name.'[]', in_array($key, (array) $value), $key)
->id($uniqueId);
$label = Html::label($option)->for($uniqueId);
$html .=
'<div class="col-md-' . $colsSize . ' col-xs-12">' .
Html::checkbox($name . '[]', in_array($key, (array) $value))
->id($uniqueId)
->value($key)
->toHtml() .
Html::label($uniqueId, $option)->toHtml() .
'<div class="col-md-'.$colsSize.' col-xs-12">'.
$checkbox.
$label.
'</div>';
}
$html .= '</div>';
Expand Down

0 comments on commit 84e978e

Please sign in to comment.