Hello,
how can I define a field in a blueprint to be a variable of type float? I want to be able to input numbers like 4.5 or 10.231 etc. and use them later in the template.
Thanks
Hello,
how can I define a field in a blueprint to be a variable of type float? I want to be able to input numbers like 4.5 or 10.231 etc. and use them later in the template.
Thanks
When you fetch data from a text file, like in $page->title()
, the type is always an object; if you fetch the value of a field ($page->title()->value()
), the type is always a string, no matter how you define your fields in the blueprint.
So the solution depends on what you want to achieve: do you want to validate the input in the panel? Then you probably need to create your own custom panel field. Otherwise, you can just use a standard text field and convert the value to float type in your template using
$float = floatval($page->field()->value());
Great, worked perfectly! Thanks