Welcome Guest, Not a member yet? Register   Sign In
codeigniter parser php issue and set value in form
#2

1.

PHP Code:
'ap_content' => $this->load->view('editproduct'''true

The second parameter of $this->load->view() is the data you are passing to the view (and this is supposed to be an array or object). Since you're loading the view into $data['ap_content'] when initially defining the $data array, you can't pass anything from $data into the view.

You could do something like this, though:

PHP Code:
$query $this->users_mod->changeProductData($idPro);
$url base_url();
$data = array(
    
'ap_heading'  => 'Edit product',
    
'base_url'    => base_url(),
    
'ap_entries'  => $query,
    
'ap_product'  => 'active',
    
'ap_username' => $this->session->userdata['logged']['username'],
);

$ap_content $this->load->view('editproduct'$datatrue);

$data['ap_content'] = $ap_content;
$this->parser->parse('template'$data); 

Note that you still wouldn't be able to access $ap_content within the editproduct view, since the 'ap_content' key wasn't set in $data when the editproduct view was loaded (and, since the content of $ap_content is the editproduct view, I wouldn't expect that to work out very well, anyway).

2.

PHP Code:
'ap_var' '<?php echo set_radio("active", "0", true); ?>' 

You could do something like this:
PHP Code:
$data = array(
    
'ap_heading'  => 'Edit product',
    
'base_url'    => base_url(),
    
'ap_entries'  => $query,
    
'ap_product'  => 'active',
    
'ap_username' => $this->session->userdata['logged']['username'],
    
'ap_var'      => set_radio("active""0"true),
);

$ap_content $this->load->view('editproduct'$datatrue);

$data['ap_content'] = $ap_content;
$this->parser->parse('template'$data); 

However, using the form helper functions this way feels really awkward.
Reply


Messages In This Thread
RE: codeigniter parser php issue and set value in form - by mwhitney - 04-27-2016, 08:16 AM



Theme © iAndrew 2016 - Forum software by © MyBB