Welcome Guest, Not a member yet? Register   Sign In
Codeigniter set_value not working
Thumbs Up 

I'm querying the DB and sending sending a $data array from my controller to my view, where I'm using CI's form helper with set_value(field_name, default) but the data is not being loaded.
This is what I'm currently doing in my view:
<input type="hidden" id="artist-id" name="record_artist_id" value="<?php echo set_value('record_artist_id', $record_artist_id); ?>">

I thought I had to use the input helper so I tried:
<label for="record-name"><span class="required">*</span>Name:</label>
                   echo form_input([
                       'type' => 'text',
                       'name' => 'record_name',
                       'id' => 'record-name' ,
                       'class' => 'form-control',
                       'value' => set_value('record_name')

But still not working.
This is working though:
<input id="record-name" name="record_name" type="text" value="<?php echo (isset($record_name)) ? $record_name : ''; ?>" class="form-control">

The form helper is being loaded in autoload.php
$autoload['helper'] = array('url', 'file', 'form', 'base');

I don't know if this is related but I'm getting the view as a string and then passing it to a template, something like:
public function add_content($view, $content = NULL){
       $this->content = $this->load->view($view, $content, TRUE);
       return $this->content;

and later on in a different method:
// render content
           $this->load->view('partials/content', ['content' => $this->content]);

Any idea about what I am doing wrong?

PHP Code:
echo form_input([
'type' => 'text',
'name' => 'record_name',
'id' => 'record-name' ,
'class' => 'form-control',
'value' => set_value('record_name',$record_name)

(This post was last modified: 03-15-2019, 01:07 PM by pippuccio76.)

i have the same  problem  the hidden fields arent set.

How can i solve it ?

Theme © iAndrew 2016 - Forum software by © MyBB