There is a critical bug in the latest release because recipe_schema() currently defines pretime as an integer field, but there is no validation on the Preparation Time field. I got a fatal error when simply leaving it blank.
I went to patch and saw that it was trying to be a select list of predefined times, but I don't think this is sufficient for this use case.
Attached is a patch that makes "preptime" a varchar field and fixes the formAPI definition.
What I meant in the title, is with more work on this patch, we could use PHPs time string functions to detect whatever people enter and translate that to seconds to store in the database. For end users, this field needs to be as flexible as possible.
Comment | File | Size | Author |
---|---|---|---|
#2 | recipe.preptime.patch | 2.42 KB | Jon Pugh |
recipe.preptime.patch | 1.79 KB | Jon Pugh |
Comments
Comment #1
Jon PughComment #2
Jon PughUpdated patch with a hook_update_N function, and a fix to the previous update_N function, which Failed if RDF module was not enabled.
Comment #3
jvandervort CreditAttribution: jvandervort commentedThe Bug wasn't in recipe, but seemed to be created by your first patch of changing the select box to a textfield. In the current alpha4, the recipe select box defaults to a value of 5 minutes (and has no "" value possible) so it would never be empty. So this is really a feature request to change the preptime to a free-typing control.
What kind of values would you want. PHP time interval handling is not that flexible.
1/2 a day.
10 minutes
1.5 hours
1-1/2 hours
2H
une heure (French, ie free typing with translations)
One hour, ten minutes
PHP can't really deal with most of these without me writing a routine to parse it myself.
http://www.php.net/manual/en/dateinterval.format.php
Would it be ok to label the box "Minutes" and then allow people to type them in?
Or an number box with a unit selectox after it?
Right now the selectbox is used so people don't have to figure out how many minutes are in 2.5 hours:)
But it is obviously inadequate if you need a value of 5-1/2 hours as it is not available.
We might need to get some more feedback from others in the community to see if there is any consensus.
Comment #4
jvandervort CreditAttribution: jvandervort commentedMoved to dev version.
Comment #5
jvandervort CreditAttribution: jvandervort commentedI was hoping for more user responses. I guess I'll have to implement something and see how people react.
Comment #6
csc4 CreditAttribution: csc4 commentedDoes seem quite wide standardisation on minutes - but there's always a risk of exceptional cases, so I think people aren't sure what to say...
Maybe not quite the right place to ask but I'd like to see cooking time done similarly - if that would be possible please ;)
Comment #7
cmurph CreditAttribution: cmurph commentedI would say that changing the select box to a text field would be easily interpreted for users to enter, as well as having the ability to have good granularity for entering preparation times and cooking times.
I'm currently playing around with getting this functionality and will post a patch for it soon hopefully. It looks to be a quick fix. I just need to change the form to a "textfield," add validation for them, and voila (hopefully).
Since the formatting of the preptime and cooktime displays are not dependent on the global variable "$_RECIPE_DURATIONS" (where the list of times for the select box is located), no other necessary code changes will probably be necessary.
However, I am looking into allowing a user to input both hours and minutes, but I wouldn't think the database would need to be changed. I stick with my above change as a first cut, and then move on from there. Comments welcomed.
Comment #8
cmurph CreditAttribution: cmurph commentedI've created a patch which converts the select box into a textbox and allows users to input minutes. When displayed, the minutes is converted to hours as necessary.
This patch is a part of the "sub recipes" patch I created for issue #776884.
To view/add the patch, go to my comment here: Issue Patch/Comment
Comment #9
jvandervort CreditAttribution: jvandervort commentedCommitted to dev, thanks.