From 2790105a7d5a33d12e914fa7cdffb6b26935bd53 Mon Sep 17 00:00:00 2001 From: Kavalar Date: Wed, 25 Dec 2024 11:40:33 +0300 Subject: [PATCH] custom select fix --- .../CustomSelectFilterForAssociativeArr.php | 20 +++++++++---------- kernel/modules/post/views/index.php | 10 +++++----- 2 files changed, 14 insertions(+), 16 deletions(-) diff --git a/kernel/filters/CustomSelectFilterForAssociativeArr.php b/kernel/filters/CustomSelectFilterForAssociativeArr.php index 6a5cbd2..86eb281 100644 --- a/kernel/filters/CustomSelectFilterForAssociativeArr.php +++ b/kernel/filters/CustomSelectFilterForAssociativeArr.php @@ -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 = ""; - return $this->html; + $select = SelectBuilder::build($this->name, [ + 'class' => 'form-control', + 'options' => $this->param, + 'value' => $this->value, + ]); + + return "" . $select->create()->fetch() . ""; } } \ No newline at end of file diff --git a/kernel/modules/post/views/index.php b/kernel/modules/post/views/index.php index bed57d6..74b84ad 100644 --- a/kernel/modules/post/views/index.php +++ b/kernel/modules/post/views/index.php @@ -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'] ?? '' ] ] ]);