CodeIgniter Forums
How to make column filled not empty while warning show up - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24)
+--- Thread: How to make column filled not empty while warning show up (/showthread.php?tid=75531)



How to make column filled not empty while warning show up - kelapamuda - 02-17-2020

Hello.

For example, i have  20 filed that user must filled  all (name, address, gender,...   etc ).
But the problem is, if user already type in 19 field, if he forgot to type in 1 field, while he click button SAVE, the warning is show up that " The bla bla bla field is required "   all 19 filled field come to empty again.  How to prevent this ?

My view for example is this :

<div class="form-group">
<label>Name</label>
<input type="text" name="name" class="form-control" placeholder="Input ur name">
<?php echo form_error('name'); ?>
</div>
          <div class="form-group">
<label>Telepon</label>
<input type="text" name="telepon" class="form-control" placeholder="Input ur telepon  ..">
<?php echo form_error('telepon'); ?>
</div>


I used not json or javascript in my CI,, only PHP as usual in insert, update database


RE: How to make column filled not empty while warning show up - muuucho - 02-18-2020

Go to the doc's Form helper section and take a look at set_value().


RE: How to make column filled not empty while warning show up - kelapamuda - 02-18-2020

Yups,,thanks for your help,  yes i added  value="<?php echo set_value('alamat_rumah' ); ?>" 

Before: 
<div class="form-group">
<label>Alamat</label>
<input type="text" name="alamat_rumah" class="form-control" placeholder="Masukkan alamat..">
<?php echo form_error('alamat_rumah'); ?>
</div>

After :
<div class="form-group">
<label>Alamat</label>
<input type="text" name="alamat_rumah" value="<?php echo set_value('alamat_rumah' ); ?>" class="form-control" placeholder="Masukkan alamat..">
<?php echo form_error('alamat_rumah'); ?>
</div>