add value to filter

This commit is contained in:
2024-08-28 15:09:34 +03:00
parent 4a15305505
commit f20f408f12
5 changed files with 17 additions and 7 deletions

View File

@ -7,10 +7,12 @@ abstract class Filter
public string $html = '';
public string|array $param;
public string $name;
public string $value;
public function __construct(array $source)
{
$this->param = $source['param'] ?? '';
$this->name = $source['name'];
$this->value = $source['value'] ?? '';
}
abstract public function fetch();

View File

@ -9,6 +9,6 @@ class InputFilter extends Filter
public function fetch()
{
return "<td><input type='$this->param' name='$this->name'></td>";
return "<td><input type='$this->param' name='$this->name' value ='$this->value'></td>";
}
}

View File

@ -11,9 +11,13 @@ class SelectFilter extends Filter
{
$this->html = "<td><select name='$this->name'>";
foreach ($this->param as $value) {
$this->html .= "<option value='$value'>$value</option>";
if ($value === $this->value) {
$this->html .= "<option value='$value' selected>$value</option>";
} else {
$this->html .= "<option value='$value'>$value</option>";
}
}
$this->html .= "</select></td>";
$this->html .= "value='$this->value'</select></td>";
return $this->html;
}
}

View File

@ -286,7 +286,8 @@ class ListJsonTable extends JasonTable
$filter = $this->getCurrentFilter($key);
$class = new $filter['class']([
'param' => $filter['param'],
'name' => $key
'name' => $key,
'value' => $filter['value']
]);
$this->html .= $class->fetch();
}