Radio button options stores first digit only
I have a radio button as follows
The corresponding fields in the database is a varchar. Filemant saves it as 0 (for 0-1 years), 1 for (1-2 years), .... 11 (for older than 10 years).
What can I do so it is saved literally as '0-1 years', '1-2 years',...?
3 Replies
what is the type of column in the DB
and do you have cast attribute in the model
Is it because your 'age' field in the db is 1-char ? You said it's varchar, but didn't say its length.
And like LaraZeus asked, is there a cast that's converting it to something else?
Does it make any difference if you pass the array a key=>value instead of just value?
eg:
(ya, the duplication isn't ideal, but does it make any difference to make the change? That may give clues to the solution)
And you could explore using an Enum for it so you don't have to maintain the options in more than one place in your app. But that can be considered later...
The corresponding fields in the database is a varchar(100) I use in the model a cast to 'string' for that column. When I do this I get an error "Array to string conversion"
This is with
as well as:
and with a cast as follows in the model
It was solved by using
but doing no cast at all in the model