php code for default values?
daneyuleb - October 26, 2008 - 06:17
| Project: | Office Hours |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed |
Jump to:
Description
Need to create 7 fields, one for each day of the week,that default to the different days (ie, day one is Sunday, day two defaults to Monday, etc.)
Is the only way to do that to create 7 fields, each with a different day default.
Or, can you make just one field, with 7 values, and use the php code option (in the default section) to cause each instance to have a different day by default. Any hints on what code could be used there to do that if it's possible? It sounds like it would be a common use to have a snippit documented for if it can be used for that..

#1
I'm not sure i understand this request, or its benefits. why would it be better to use a single field? can you give a use case?
#2
Sorry. I didn't realize that adding additional values to a single field -does- cause the days to increment for each new field. So...adding 7 fields, does give me:
Saturday
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
(For some reason when I first implemented it they were not incrementing, and all were being created at None except the first (default) one, which would have meant I would have had to add 7 separate fields or come up with some default changing php code. But...I it's incrementing as I would expect now. Guess I was confused.
By the way, I do find I have to make the first value Saturday in a 7 value field, as the 2nd value always starts at Sunday. No problem there, but I would have expected it to always make the 2nd day based on day following the first value....if I were to pick a default of Monday, the 2nd value should come in at Tuesday, then Wednesday, etc.
This is a very helpful module by the way---thank you very much for creating it!
#3