mirror of
https://code.castopod.org/adaures/castopod.git
synced 2024-09-10 20:43:22 +02:00
- update Component class structure and remove component helper function and ComponentLoader - update residual activitypub naming to fediverse
42 lines
911 B
PHP
42 lines
911 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\View\Components\Forms;
|
|
|
|
use ViewComponents\Component;
|
|
|
|
class MultiSelect extends Component
|
|
{
|
|
/**
|
|
* @var array<string, string>
|
|
*/
|
|
protected array $options = [];
|
|
|
|
/**
|
|
* @var string[]
|
|
*/
|
|
protected array $selected = [];
|
|
|
|
public function setOptions(string $value): void
|
|
{
|
|
$this->options = json_decode(html_entity_decode($value), true);
|
|
}
|
|
|
|
public function setSelected(string $selected): void
|
|
{
|
|
$this->selected = json_decode($selected);
|
|
}
|
|
|
|
public function render(): string
|
|
{
|
|
$defaultAttributes = [
|
|
'data-class' => $this->attributes['class'],
|
|
'multiple' => 'multiple',
|
|
];
|
|
$extra = array_merge($defaultAttributes, $this->attributes);
|
|
|
|
return form_dropdown($this->attributes['name'], $this->options, $this->selected, $extra);
|
|
}
|
|
}
|