html_helper.php 555 B

1234567891011121314151617181920212223242526
  1. <?php
  2. class HtmlHelper {
  3. public static function selected(?string $value, ?string $selected): string {
  4. return ((string) $value === (string) $selected) ? "selected" : "";
  5. }
  6. public static function renderOptions(array $options, ?string $selected): void {
  7. foreach($options as $value => $display) {
  8. ?>
  9. <option value="<?=$value?>" <?=self::selected($value, $selected)?>>
  10. <?=htmlspecialchars($display)?>
  11. </option>
  12. <?php
  13. }
  14. }
  15. public static function getYesNoOptions(): array {
  16. return [
  17. 1 => __("Yes"),
  18. 0 => __("No")
  19. ];
  20. }
  21. }