lundi 31 août 2015

How to simplify form with multiple identical rows?

Want an advice.. I need a module - "working hours". Just simple: Monday: 10:00 - 18:00 ... Saturday: 11:00-16:00 (some extra info).

I am trying ..

<form  id="working_hours" >
       <select name="city" id="city_working_hours"/>
      city select
            </select>  
  <label>Choose day and hours </label>
<?php foreach ($days as $key=>$value): ?>
<label> <?php echo $value;?>  </label>
open <input type="text"  name="<?php echo $key;?>_open" value="" class="time_input"/>  
   close <input type="text"  name="<?php echo $key;?>_close" value="" class="time_input"/> 
   extra <input type="text"  name="<?php echo $key;?>_extra"  value="" />

From array $days=array("monday=>"Monday", ..., "sunday"=>"Sunday").

The DB structure seems as

CITY| DAY | OPEN | CLOSE | EXTRA

7 rows per city

But it seems that it would be diff to serialize such a form. Maybe a table with a day=row (and then jquery.each), or separate form for each day? Would aprreciate any advice. I am sure that there is a simple solution...




Aucun commentaire:

Enregistrer un commentaire