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
|
* @param string $action
|
||||||
* @return void
|
* @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
|
public function createOption(array $options, $value = null): string
|
||||||
{
|
{
|
||||||
$optionsString = "";
|
$optionsString = "";
|
||||||
foreach ($options as $val => $title){
|
if (is_array($value)) {
|
||||||
$selected = (int)$value === $val ? "selected" : "";
|
foreach ($options as $val => $title) {
|
||||||
$optionsString .= "<option $selected value='$val'>$title</option>";
|
$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;
|
return $optionsString;
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user