I am trying to make an edit page where the form fields are populated from the database. I'm trying to get it working by just setting some random text, but I'm having trouble making it show.
I have the following in my controller:
public function edit($item_id) {
$this->data['title'] = "Edit Item";
$this->data['item_title'] = array(
'name' => 'item_title',
'id' => 'item_title',
'type' => 'text',
'value' => 'a title',
);
$this->data['url_slug'] = array(
'name' => 'url_slug',
'id' => 'url_slug',
'type' => 'text',
'value' => 'some-url-slug',
);
$this->template->build('admin/item/form', $this->data);
}
This is my view:
<?php echo form_open('admin/item/update_item', array('id' => 'item_form')); ?>
<input type="text" name="item_title" value="<?php echo set_value('item_title'); ?>" id="item_title" placeholder="Enter a title..."/>
<input type="text" name="url_slug" value="<?php echo set_value('url_slug'); ?>" id="url_slug" placeholder="url-slug-of-the-item"/>
When I go the /edit/id page, the placeholder is still showing and the value is blank. Why is not setting? It works fine when I use it for form validation.
item_titleandurl_slugarearrays butvalueattribute must be of string.