Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When model binding includes a bool what string value must the form collection contain?

If I am using model binding and one of the variables in the model is a bool what string must the form collection contain to be considered true or false?

So for example if my model has a variable:

bool isHappy;

Now when the model binder reads the form collection and it contains name "isHappy" what will the value have to be? "true", "checked", "1", etc?

like image 594
MetaGuru Avatar asked Feb 03 '23 16:02

MetaGuru


1 Answers

It will be "true" or "false". Note that it's case insensitive so "True", "False", "TRUE", "FALSE" also work.

like image 174
Haacked Avatar answered May 10 '23 20:05

Haacked