Hello Team,
I use Laravel 6 with Bootstrap:
I saw a new problem. I have Categories with Parent Categories. If i check a radio button, then i can not uncheck in my form.
Yes, i can make a standart category_base, and make a if statement and set parent_id to "NULL". But the problem is, in the future i loaded allways this category_base in my "foreach" blade files. I think that is not the best solution.
How you deal with this? Do you make this with javascript, all what is the best way?
Many thanks.
Radio buttons are use when there is a limited amount of values that can be grouped and are required like < 18 or > 18. For optional values a checkbox should always be used.
Yes that would work but it's not a good practice to use a hammer to remove screws from a wall. It sure works but it's not the correct tool for the trade.
@tray2 and why isn't it? That's the off state that @sinnbeck suggested. I would go with the same, because he either needs 1 parent ID or no parent ID (from a list of parent categories so it is not just black or white). Checkboxes in this case won't work because he has more than 1 parent categories.
@nakov The question asked about unchecking a radiobutton and the only way to do that is by clicking another one in that group. If there were only one radiobutton it would be much better to have a checkbox. If there are multiple values and only one should be used I would not use checkboxes (Maybe a select though).
@tray2 Yeah, a <select> is a better alternative to a radio buttons if there are many parent categories. Select with default "No parent" category option would do the same.