Expand forms and improve validation for multi-account piggy banks

This commit is contained in:
James Cole
2024-12-06 08:10:31 +01:00
parent 4819b5ac5d
commit ea4be9dd0c
16 changed files with 149 additions and 57 deletions

View File

@@ -56,6 +56,25 @@ trait FormSupport
return $html;
}
public function multiSelect(string $name, ?array $list = null, $selected = null, ?array $options = null): string
{
$list ??= [];
$label = $this->label($name, $options);
$options = $this->expandOptionArray($name, $label, $options);
$classes = $this->getHolderClasses($name);
$selected = $this->fillFieldValue($name, $selected);
unset($options['autocomplete'], $options['placeholder']);
try {
$html = view('form.multi-select', compact('classes', 'name', 'label', 'selected', 'options', 'list'))->render();
} catch (\Throwable $e) {
app('log')->debug(sprintf('Could not render multi-select(): %s', $e->getMessage()));
$html = 'Could not render multi-select.';
}
return $html;
}
protected function label(string $name, ?array $options = null): string
{
$options ??= [];