0

i want to create a edit form in my project but when i try to set the old values i cant with the date value, is empty. (i'm working with mysql, Js and this form is in handlebars)

This is the route:

router.get('/edit/:id', async(req,res)=>{    
     const { id }=req.params;     
     const casos = await pool.query('SELECT * FROM casos WHERE id=?',[id]);     
      res.render('casos/edit',{casos:casos[0]}); });

i tried something like this:

<div class="col-md-4">  
  <label>Fecha de cirugía</label>  
   <input type="date" value="{{casos.fechacirugia}}" class="form-control" name="fechacirugia"/>  
</div>

I want to get a input with the db value

Shadow
  • 33,525
  • 10
  • 51
  • 64

1 Answers1

0

try this instead the ternary operator to set the default key

<input type="date" value="{{casos.fechacirugia? casos.fechacirugia: 'default_value'}}" class="form-control" name="fechacirugia"/>