Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
htmlhelper.php
1<?php
2
4
5
6final class HtmlHelper
7{
8 public static function generateSelect($id, array $selectData, $value, array $params = array())
9 {
10 $html = '<select name="' . $id . '" id="' . $id . '"';
11 foreach($params as $param)
12 {
13 $html .= ' ' . $param;
14 }
15 $html .= '>';
16
17 foreach($selectData as $key => $val)
18 {
19 $html .=
20 '<option value="' . htmlspecialcharsbx($key) . '"' . ($value == $key ? ' selected' : '') . '>' .
21 htmlspecialcharsex($val) .
22 '</option>';
23 }
24 $html .= '</select>';
25
26 return $html;
27 }
28
29 public static function generateMultipleSelect($id, array $selectData, array $values, array $params = array())
30 {
31 $html = '<select multiple name="' . $id . '" id="' . $id . '"';
32 foreach($params as $param)
33 {
34 $html .= ' ' . $param;
35 }
36 $html .= '>';
37
38 foreach($selectData as $key => $val)
39 {
40 $html .=
41 '<option value="' . htmlspecialcharsbx($key) . '"' . (in_array($key, $values) ? ' selected' : '') . '>' .
42 htmlspecialcharsex($val) .
43 '</option>';
44 }
45 $html .= '</select>';
46
47 return $html;
48 }
49}
static generateSelect($id, array $selectData, $value, array $params=array())
Definition htmlhelper.php:8
static generateMultipleSelect($id, array $selectData, array $values, array $params=array())