mzur / kirby-form

A form helper for Kirby CMS based websites and apps, using the Post/Redirect/Get pattern.
MIT License
8 stars 6 forks source link

Add support for fallback value other than '' in $form->old() #17

Closed adamkiss closed 1 year ago

adamkiss commented 1 year ago

Allows you to define your own fallback value if the field wasn't found in the flash, like so:

$form->old('field', null);
$form->old('field', 0);
$form->old('field', 'whatever');

the reason for this: if you're building your input programmatically, like so:

echo Html::tag('input', '', ['value'=>$form->old('field')]);

Kirby now throws a depreciation warning about passing an empty string as the value, and requires a null to properly decide to omit the attribute.

Currently the best option is to use $form->old('field') ?: null (as I do now), but I think being more explicit about the default value would be better.