Codeigniter_Blog_App/application/views/posts/edit.php

26 lines
1.0 KiB
PHP
Raw Permalink Normal View History

2024-07-11 04:23:32 +00:00
<h2><?= $title; ?></h2>
<?= validation_errors(); ?>
<!--The data is submitted to the Posts controller and update method-->
<?= form_open('posts/update');?>
<!--Both the $post and $category are from the $data array in which we passed from the Posts controller edit method-->
<input type = "hidden" name = "id" value = "<?= $post['id']?>">
<div class="form-group">
<label >Title</label>
<input type="text" class="form-control" name="title" placeholder="Add title" value="<?= $post['title']; ?>">
</div>
<div class="form-group">
<label>Body</label>
<textarea id="editor1" class="form-control" name="body"
placeholder="Add Body"><?= $post['body']; ?></textarea>
</div>
<div class = "form-group">
<label>Category</label>
<select name="category_id" class="form-control">
<?php foreach($categories as $category): ?>
<option value="<?= $category['id']; ?>"><?= $category['name']; ?></option>
<?php endforeach; ?>
</select>
</div>
<button type="submit" class="btn btn-default">Submit</button>
</form>