Skip to content

Commit c6426c6

Browse files
fix: improve setup and error handling
1 parent f407535 commit c6426c6

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

InputfieldMarkup.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ class='rcp-color $selected'
1515
title='{$col->label}' uk-tooltip
1616
>$html</div>";
1717
}
18+
if (!$f->colors()->count()) {
19+
echo "setup your field in init.php";
20+
}
1821
?>
1922
<input type="text" id="<?= $f->id ?>" class="uk-input" name="<?= $f->name ?>" value="<?= $value ?>">
2023
</div>

InputfieldRockColorPicker.module.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ public function colors()
2727
{
2828
$name = $this->name;
2929
if ($i = strpos($name, "_repeater")) $name = substr($name, 0, $i);
30-
return $this->master()->colors()->get($name);
30+
$colors = $this->master()->colors()->get($name);
31+
if (!$colors instanceof WireArray) return new WireArray();
32+
return $colors;
3133
}
3234

3335
public function master(): RockColorPicker
@@ -45,7 +47,7 @@ public function ___render()
4547
if ($val instanceof WireData) $val = $val->name;
4648
return $this->wire->files->render(
4749
__DIR__ . "/InputfieldMarkup.php",
48-
['f' => $this, 'value' => $val]
50+
['f' => $this, 'value' => $val ?: false]
4951
);
5052
}
5153

RockColorPicker.module.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public static function getModuleInfo()
1818
{
1919
return [
2020
'title' => 'RockColorPicker',
21-
'version' => '1.2.0',
21+
'version' => '1.2.1',
2222
'summary' => 'Main RockColorPicker Module',
2323
'autoload' => false,
2424
'singular' => true, // sic

0 commit comments

Comments
 (0)