Make Stack Field sortable #4346
-
It would be useful to make the stack field sortable, for example: Stack::make('Employee', [
Text::make('Name')->sortable(),
Text::make('Surname')->sortable(),
]), this should sort by Or again Stack::make('Employee', [
Line::make('Employee')->asHeading()->sortable(),
Line::make('Role')->asSubTitle(),
]), this should jsut sort by Employee. |
Beta Was this translation helpful? Give feedback.
Answered by
davidhemphill
Jun 1, 2022
Replies: 1 comment 1 reply
-
Stack fields already support sorting by setting the attribute as the second argument: Stack::make('Employee', 'employee', [
Text::make('Name')->sortable(),
Text::make('Surname')->sortable(),
]), /**
* Create a new Stack field.
*
* @param string $name
* @param string|array<int, class-string<\Laravel\Nova\Fields\Field>|callable>|null $attribute
* @param array<int, class-string<\Laravel\Nova\Fields\Field>|callable> $lines
* @return void
*/
public function __construct($name, $attribute = null, $lines = [])
{
if (is_array($attribute)) {
$lines = $attribute;
$attribute = null;
}
parent::__construct($name, $attribute);
$this->lines = $lines;
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
davidhemphill
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Stack fields already support sorting by setting the attribute as the second argument: