public static function selectbox($fieldName, $dataOptions, $args = '') { if (empty($dataOptions) || !is_array($dataOptions)) { return false; } $Field = new self($fieldName, $args); $value = $Field->getValue(); $name = $Field->getName(); $html_options = $Field->getHtmlOptions(); if (!empty($html_options['multiple'])) { $name .= '[]'; } $options[] = '<select name="' . $name . '" ' . $html_options . '>'; foreach ($dataOptions as $optionKey => $optionValue) { if ($value == $optionKey) { $selected = 'selected="selected"'; } elseif (is_array($value) and in_array($optionKey, $value)) { $selected = 'selected="selected"'; } else { $selected = ''; } $options[] = '<option value="' . $optionKey . '" ' . $selected . '>' . $optionValue . '</option>'; } $options[] = '</select>'; $separator = empty($args['separator']) ? '' : $args['separator']; return implode($separator, $options); }