custom select fix
This commit is contained in:
parent
f0bda2ee24
commit
2790105a7d
@ -2,23 +2,21 @@
|
|||||||
|
|
||||||
namespace kernel\filters;
|
namespace kernel\filters;
|
||||||
|
|
||||||
|
use itguild\forms\builders\SelectBuilder;
|
||||||
use Itguild\Tables\Filter\Filter;
|
use Itguild\Tables\Filter\Filter;
|
||||||
use kernel\helpers\Debug;
|
use kernel\helpers\Debug;
|
||||||
|
|
||||||
class CustomSelectFilterForAssociativeArr extends Filter
|
class CustomSelectFilterForAssociativeArr extends Filter
|
||||||
{
|
{
|
||||||
|
|
||||||
public function fetch()
|
public function fetch(): string
|
||||||
{
|
{
|
||||||
$this->html = "<td><select class='form-control' name='$this->name'>";
|
$select = SelectBuilder::build($this->name, [
|
||||||
foreach ($this->param as $key => $value) {
|
'class' => 'form-control',
|
||||||
if ($key == $this->value) {
|
'options' => $this->param,
|
||||||
$this->html .= "<option value='$key' selected>$value</option>";
|
'value' => $this->value,
|
||||||
} else {
|
]);
|
||||||
$this->html .= "<option value='$key'>$value</option>";
|
|
||||||
}
|
return "<td>" . $select->create()->fetch() . "</td>";
|
||||||
}
|
|
||||||
$this->html .= "value='$this->value'</select></td>";
|
|
||||||
return $this->html;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ use kernel\widgets\IconBtn\IconBtnDeleteWidget;
|
|||||||
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
use kernel\widgets\IconBtn\IconBtnEditWidget;
|
||||||
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
use kernel\widgets\IconBtn\IconBtnViewWidget;
|
||||||
|
|
||||||
$request = (new \kernel\Request())->get();
|
$get = (new \kernel\Request())->get();
|
||||||
|
|
||||||
$table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
|
$table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
|
||||||
'currentPage' => $page_number,
|
'currentPage' => $page_number,
|
||||||
@ -23,7 +23,7 @@ $table = new ListEloquentTable(new EloquentDataProvider(Post::class, [
|
|||||||
'params' => ["class" => "table table-bordered", "border" => "2"],
|
'params' => ["class" => "table table-bordered", "border" => "2"],
|
||||||
'baseUrl' => "/admin/post",
|
'baseUrl' => "/admin/post",
|
||||||
'searchPrefix' => "",
|
'searchPrefix' => "",
|
||||||
'searchParams' => (new \kernel\Request())->get()
|
'searchParams' => $get
|
||||||
]));
|
]));
|
||||||
|
|
||||||
//\kernel\helpers\Debug::dd((new \kernel\Request())->get());
|
//\kernel\helpers\Debug::dd((new \kernel\Request())->get());
|
||||||
@ -48,13 +48,13 @@ $table->columns([
|
|||||||
'title' => [
|
'title' => [
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
|
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
|
||||||
'value' => $request['title'] ?? ''
|
'value' => $get['title'] ?? ''
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'content' => [
|
'content' => [
|
||||||
'filter' => [
|
'filter' => [
|
||||||
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
|
'class' => \Itguild\Tables\Filter\InputTextFilter::class,
|
||||||
'value' => $request['content'] ?? ''
|
'value' => $get['content'] ?? ''
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
'created_at' => [
|
'created_at' => [
|
||||||
@ -74,7 +74,7 @@ $table->columns([
|
|||||||
'filter' => [
|
'filter' => [
|
||||||
'class' => \kernel\filters\CustomSelectFilterForAssociativeArr::class,
|
'class' => \kernel\filters\CustomSelectFilterForAssociativeArr::class,
|
||||||
'param' => \kernel\modules\user\service\UserService::createUsernameArr(),
|
'param' => \kernel\modules\user\service\UserService::createUsernameArr(),
|
||||||
'value' => $request['user_id'] ?? ''
|
'value' => $get['user_id'] ?? ''
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user