first commit
This commit is contained in:
21
traits/CreateOption.php
Executable file
21
traits/CreateOption.php
Executable file
@ -0,0 +1,21 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\form\traits;
|
||||
|
||||
trait CreateOption
|
||||
{
|
||||
/**
|
||||
* @param array $options
|
||||
* @param $value
|
||||
* @return string
|
||||
*/
|
||||
public function createOption(array $options, $value = null): string
|
||||
{
|
||||
$optionsString = "";
|
||||
foreach ($options as $val => $title){
|
||||
$selected = (int)$value === $val ? "selected" : "";
|
||||
$optionsString .= "<option $selected value='$val'>$title</option>";
|
||||
}
|
||||
return $optionsString;
|
||||
}
|
||||
}
|
24
traits/CreateParams.php
Executable file
24
traits/CreateParams.php
Executable file
@ -0,0 +1,24 @@
|
||||
<?php
|
||||
|
||||
namespace itguild\forms\form\traits;
|
||||
|
||||
trait CreateParams
|
||||
{
|
||||
|
||||
/**
|
||||
* @param array $data
|
||||
* @return string
|
||||
*/
|
||||
public function createParams(array $data = []): string
|
||||
{
|
||||
$paramsString = "";
|
||||
foreach($data as $key => $param){
|
||||
if(is_string($param)){
|
||||
$paramsString .= $key . "='" . $param . "'";
|
||||
}
|
||||
}
|
||||
|
||||
return $paramsString;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user