rockettheme / toolbox

RocketTheme\Toolbox package contains a set of reusable PHP interfaces, classes and traits.
MIT License
21 stars 16 forks source link

'ordering@' => 0 does not work #33

Open drzraf opened 2 years ago

drzraf commented 2 years ago

... because https://github.com/rockettheme/toolbox/blob/8ad2b96846eb3c32874fdbe08e01d37bfc2c9fea/Blueprints/src/BlueprintForm.php#L438 keeps $order from being set if the location is 0 because the conditional does not distinguish between 0 and the empty string.

drzraf commented 2 years ago

As a consequence we can't order as the first element. Documentation (https://learn.getgrav.org/17/forms/blueprints/advanced-features#changing-field-ordering) states that -1 should be used.

But using -1 triggers this: https://github.com/rockettheme/toolbox/blob/8ad2b96846eb3c32874fdbe08e01d37bfc2c9fea/Blueprints/src/BlueprintForm.php#L627-L630 ... which, as expected by https://www.php.net/manual/en/function.array-splice.php put the extracted element at the end of the list.

drzraf commented 2 years ago

My suggestion is to not drop explicit 0 value. A quick way is changing line 438 by if ($location || $location === 0) {