custom select fix

This commit is contained in:
Kavalar 2024-12-25 11:40:33 +03:00
parent f0bda2ee24
commit 2790105a7d
2 changed files with 14 additions and 16 deletions

View File

@ -2,23 +2,21 @@
namespace kernel\filters;
use itguild\forms\builders\SelectBuilder;
use Itguild\Tables\Filter\Filter;
use kernel\helpers\Debug;
class CustomSelectFilterForAssociativeArr extends Filter
{
public function fetch()
public function fetch(): string
{
$this->html = "<td><select class='form-control' name='$this->name'>";
foreach ($this->param as $key => $value) {
if ($key == $this->value) {
$this->html .= "<option value='$key' selected>$value</option>";
} else {
$this->html .= "<option value='$key'>$value</option>";
}
}
$this->html .= "value='$this->value'</select></td>";
return $this->html;
$select = SelectBuilder::build($this->name, [
'class' => 'form-control',
'options' => $this->param,
'value' => $this->value,
]);
return "<td>" . $select->create()->fetch() . "</td>";
}
}

View File

@ -15,7 +15,7 @@ use kernel\widgets\IconBtn\IconBtnDeleteWidget;
use kernel\widgets\IconBtn\IconBtnEditWidget;
use kernel\widgets\IconBtn\IconBtnViewWidget;
$request = (new \kernel\Request())->get();
$get = (new \kernel\Request())->get();
$table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'currentPage' => $page_number,
@ -23,7 +23,7 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
'params' => ["class" => "table table-bordered", "border" => "2"],
'baseUrl' => "/admin/post",
'searchPrefix' => "",
'searchParams' => (new \kernel\Request())->get()
'searchParams' => $get
]));
//\kernel\helpers\Debug::dd((new \kernel\Request())->get());
@ -48,13 +48,13 @@ $table->columns([
'title' => [
'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
'value' => $request['title'] ?? ''
'value' => $get['title'] ?? ''
]
],
'content' => [
'filter' => [
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
'value' => $request['content'] ?? ''
'value' => $get['content'] ?? ''
]
],
'created_at' => [
@ -74,7 +74,7 @@ $table->columns([
'filter' => [
'class' => \kernel\filters\CustomSelectFilterForAssociativeArr::class,
'param' => \kernel\modules\user\service\UserService::createUsernameArr(),
'value' => $request['user_id'] ?? ''
'value' => $get['user_id'] ?? ''
]
]
]);