Form Submit hours of operation

@Sean_Knight - this may or may not be useful for you, but it is what @Robert_Petitto referred to in his earlier reply.

Typically, for this sort of thing there are two approaches you can take.

The first approach involves creating a series of columns in your Businesses table. Essentially a pair of Open/Close time columns for each day of the week. This approach is okay, but can become a bit fiddly if you ever want to present them as a list. It’s the approach that Bob alluded to here…

The second approach would involve creating a second table, and using one row per day per business, and then relating that back to your Businesses table. This approach is much cleaner, but can eat up your row count very quickly.

What I am sharing below introduces a third approach, where you store the open/close times for each business in a single column in the Businesses table as a JSON object, and use a helper table to manipulate the object. This is a technique that I’ve been developing over the past few months and have used in a handful of projects.

Here is a video that gives a walk through of how it works:

And here is a copyable template:

@Robert_Petitto - I’m not sure if you ended up using this idea in your project, but just in case - there are a couple of things I’ve changed in this template version:

  • I’ve abandoned the JQ plugin in favour of pure JavaScript. I did this because in one of my other projects I found that the JQ plugin doesn’t scale well.
  • I fixed the bug where the hour of the day comparison sometimes doesn’t work (for partial hours)
  • I found and fixed another bug where editing hours sometimes didn’t save correctly. This bug was a side effect of the fact that you can’t reset multiple rows with a single action. Fixed this with a variant of @Jeff_Hager’s parent_id approach.