在Codeigniter中修改时编辑日期

I have a date input to register dates on a form. Dates are recorded and displayed correctly. The problem comes when I want to edit the saved date, I need to show me the saved date in order to make changes.

This is my code for the date input :

<p>
  <label>Fecha:</label>
  <p type="Fecha:">
    <input type="date" name="fecha" step="1" value="<?php echo date("Y-m-d");?>" autocomplete="off" required value="<?php echo $fecha; ?>" />
    <?php echo form_error("fecha","<span class='help-block'>","</span>") ?> 
  </p>
</p>
douliang2087
douliang2087 试试这个<p><label>Fecha:</label><ptype=“Fecha:”><inputtype=“date”name=“fecha”step=“1”autocomplete=“off”requiredvalue=“<?phpechoset_value('fecha',!empty($fecha)?$fecha:date('Ym-d'));?>“/><?phpechoform_error(”fecha“,”<spanclass='help-block'>“,”</span>“)?></p></p>
11 个月之前 回复
dongtangjie0495
dongtangjie0495 您有两个值属性,因为您只传递一个参数到日期,它将显示当前日期。
11 个月之前 回复
duangengruan2144
duangengruan2144 编辑为<?phpecho$fecha?>时需要显示保存的日期
11 个月之前 回复

1个回答

You are using double value attributes in the input. Please remove one and put values in the condition.

<p><label>Fecha:</label> <p type="Fecha:"><input type="date" name="fecha" step="1" value="<?php if(!empty($fecha)){ echo $fecha; } else { echo date("Y-m-d"); } ?>" autocomplete="off" required  /><?php echo form_error("fecha","<span class='help-block'>","</span>") ?> </p></p>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问