<?php
$funcArgs = [];
if (isset($selected)) {
  $funcArgs[] = "'".$selected."'";
} else if (isset($selectedJS)) {
  $funcArgs[] = $selectedJS;
}
else {
  $funcArgs[] = 'null';
}
if (isset($list)) {
  $funcArgs[] = htmlentities(json_encode($list));
}
$funcArgs = implode(', ', $funcArgs);
?>
<select
  x-data="selectCategory(<?php echo $funcArgs; ?>)"
  name="<?php echo $name; ?>"
  id="<?php echo $id ?? null; ?>"
  <?php echo isset($placeholder) ? 'placeholder="'. $placeholder .'"' : null; ?>
  <?php echo isset($onChange) ? 'x-init="onChange('. $onChange .')"' : null; ?>
>
  <?php if (isset($placeholder)): ?>
    <option></option>
  <?php endif; ?>
</select>