Merge branch 'master' of https://git.itguild.info/ItGuild/forms_bundle
This commit is contained in:
commit
53e5fadfc1
@ -31,9 +31,9 @@ class ActiveForm
|
||||
* @param string $action
|
||||
* @return void
|
||||
*/
|
||||
public function beginForm(string $action): void
|
||||
public function beginForm(string $action, string $enctype = 'application/x-www-form-urlencoded'): void
|
||||
{
|
||||
echo "<form method='POST' action='$action'>";
|
||||
echo "<form method='POST' action='$action' enctype='$enctype'>";
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,10 +12,18 @@ trait CreateOption
|
||||
public function createOption(array $options, $value = null): string
|
||||
{
|
||||
$optionsString = "";
|
||||
foreach ($options as $val => $title){
|
||||
if (is_array($value)) {
|
||||
foreach ($options as $val => $title) {
|
||||
$selected = in_array($title, $value) ? "selected" : "";
|
||||
$optionsString .= "<option $selected value='$val'>$title</option>";
|
||||
}
|
||||
} else {
|
||||
foreach ($options as $val => $title) {
|
||||
$selected = (int)$value === $val ? "selected" : "";
|
||||
$optionsString .= "<option $selected value='$val'>$title</option>";
|
||||
}
|
||||
}
|
||||
|
||||
return $optionsString;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user