Compare commits
4 Commits
0.1.3
...
53e5fadfc1
Author | SHA1 | Date | |
---|---|---|---|
53e5fadfc1 | |||
9dfb6a52c3 | |||
45e57367d3 | |||
ddb17cc473 |
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ trait CreateParams
|
|||||||
{
|
{
|
||||||
$paramsString = "";
|
$paramsString = "";
|
||||||
foreach($data as $key => $param){
|
foreach($data as $key => $param){
|
||||||
if(is_string($param)){
|
if(is_string($param) || is_numeric($param)){
|
||||||
$paramsString .= $key . "='" . $param . "'";
|
$paramsString .= $key . "='" . $param . "'";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user