I don't know if this has been addressed yet in the official source or in the forums, but here goes...
If you're like me, you might've noticed the validation for time entries is a tad lacking (save in the QuickAdd form, which I until now never noticed - heh):
- The ticket time entry "pop-up" does not do ANY validation whatsoever
- The regular time entry only does "required field" validation
Though the second I fixed within minutes, I spent some time banging my head against the desk for the first one. It turns out that (almost) the only reason it doesn't do what it's supposed do is because it's missing an ID!
Summary of changes: public/assets/modules/timetracking/javascript/main.js
In App.TimePopup's init_popup function, find (for me this was line 317):
var popup_wrapper = form.parent().parent();
Before that line, add:
if(UniForm.validate(form, true)) {
Then move down to:
return false;
And add a } before that line.
This will force validation to succeed before the form actually submits (GRR!).
activecollab/application/modules/timetracking/views/timetracking/index.tpl
Find (line 49 for me):
This will add numerical/decimal validation to the time entry. AC includes a very nice jQuery plug-in to do this and doesn't use it (much)! A pity, really.
activecollab/application/modules/timetracking/views/_popup.tpl
Find (line 25 for me):
As far as I know, what the ID is doesn't really matter. I made this one long so that it wouldn't conflict with anything else (hopefully). Show errors=no makes the validation error TEXT not show (but the fields are still highlighted). Given the layout of the form, showing the text here is kind of ugly, but it's really up to you.
Find (line 29 for me, four lines below the edit above):
If you're like me, you might've noticed the validation for time entries is a tad lacking (save in the QuickAdd form, which I until now never noticed - heh):
- The ticket time entry "pop-up" does not do ANY validation whatsoever
- The regular time entry only does "required field" validation
Though the second I fixed within minutes, I spent some time banging my head against the desk for the first one. It turns out that (almost) the only reason it doesn't do what it's supposed do is because it's missing an ID!
Summary of changes:
public/assets/modules/timetracking/javascript/main.js
In App.TimePopup's init_popup function, find (for me this was line 317):
Before that line, add:
if(UniForm.validate(form, true)) {Then move down to:
And add a } before that line.
This will force validation to succeed before the form actually submits (GRR!).
activecollab/application/modules/timetracking/views/timetracking/index.tpl
Find (line 49 for me):
{text_field name='time[value]' value=$timetracking_data.value id=time_hours class='short required'}In the class, add validate_number as such:
{text_field name='time[value]' value=$timetracking_data.value id=time_hours class='short required validate_number'}This will add numerical/decimal validation to the time entry. AC includes a very nice jQuery plug-in to do this and doesn't use it (much)! A pity, really.
activecollab/application/modules/timetracking/views/_popup.tpl
Find (line 25 for me):
{form action=$add_url method=post}Add a an id and show_errors=no, e.g.:
{form action=$add_url method=post id=add_time_record_form_for_tickets show_errors=no}As far as I know, what the ID is doesn't really matter. I made this one long so that it wouldn't conflict with anything else (hopefully). Show errors=no makes the validation error TEXT not show (but the fields are still highlighted). Given the layout of the form, showing the text here is kind of ugly, but it's really up to you.
Find (line 29 for me, four lines below the edit above):
{text_field name='time[value]' id=timeRecordValue class='short required'}Again, add validate_number:
{text_field name='time[value]' id=timeRecordValue class='short required validate_number'}Phew! No more accidentally lost entries.