| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- namespace App\Helpers;
- use App\Interfaces\OptionInterface;
- class HtmlHelper {
- public static function renderOptions(array $options, $selected_value = null): void {
- foreach($options as $i => $x) {
- if($x instanceof OptionInterface) {
- $value = $x->getOptionValue();
- $label = $x->getOptionLabel();
- }
- else {
- $value = $i;
- $label = $x;
- }
- $selected = ((string) $value === (string) $selected_value) ? "selected" : "";
- ?>
- <option value="<?=htmlspecialchars($value)?>" <?=$selected?>>
- <?=htmlspecialchars($label)?>
- </option>
- <?php
- }
- }
- public static function renderInfoAlert(string $message): void {
- ?>
- <div class="alert alert-info">
- <i class="fa fa-fw fa-info-circle"></i>
- <?=htmlspecialchars($message)?>
- </div>
- <?php
- }
- public static function readonly($value): string {
- return $value ? "readonly" : "";
- }
- public static function hidden($value): string {
- return $value ? "hidden" : "";
- }
- public static function required($value): string {
- return $value ? "required" : "";
- }
- }
|