Welcome Guest, Not a member yet? Register   Sign In
Data type edit input
#3

I was looking for a way to trace an input date, the date saved in the database in strtotime().

I solved it like this:


PHP Code:
<div class="form-group mb-3 row">
     <label class="form-label col-3 col-form-label">Birth Date</label>
      <div class="col">
         <input type="date" name="birth" class="form-control" value="<?= isset($item->birth) ? set_value('birth', date('Y-m-d', $item->birth)) : set_value('birth'); ?>">
         <?= $validation->showError('birth'?>
     </div>
</div> 


But now with the same speech, I can not show the category already present referred to a post, selected. I don't know how to explain it better, but imagine that you are editing a post and want to show yourself selected from a list, the category to which it belongs.

PHP Code:
<?php if (!empty($categories) && is_array($categories)) : ?>
<?php 
foreach($categories as $cat): ?>
<label class="form-selectgroup-item">
    <input type="radio" name="category" value="<?= $cat->id?>" class="form-selectgroup-input" <?= set_radio('category'$cat->id); ?>>
        <span class="form-selectgroup-box"><?= $cat->category_name?></span>
</label>
      <?php endforeach; ?>
  <?php else : ?>
     <span class="text-danger">There are no categories. <strong><a href="<?= site_url('admin/add_categories'); ?>">Add categories</a></strong> before inserting a new obituary.</span>
   <?php endif; ?>

I tried this, but it doesn't work (it shows the selected only after choosing a category and keeps it, but I want it to show me initially selected the category in which it is already present.)
Reply


Messages In This Thread
Data type edit input - by Marcolino92 - 04-30-2020, 12:32 AM
RE: Data type edit input - by php_rocs - 04-30-2020, 05:16 PM
RE: Data type edit input - by Marcolino92 - 05-01-2020, 12:17 AM
RE: Data type edit input - by php_rocs - 05-01-2020, 12:11 PM



Theme © iAndrew 2016 - Forum software by © MyBB