Welcome Guest, Not a member yet? Register   Sign In
$this->input->post / DMZ / Datamapper
#1

[eluser]akzidenz[/eluser]
Hi there

Newish to CI but this is slightly weird. I am trying to access the post class inside
a DMZ model to no luck. I'm trying to get 'title' but the page is blank.
$_POST['title'] however is fine, but I am trying to stick to CI standards.

Accessing it in the controller is also fine but, within a model is not?
Or is it a DMZ problem? Code for the model is below.

Any ideas?
Thanks!
Kenny

Code:
<?php

class Category extends DataMapper {

    var $has_one = array('asset', 'type');

    public function __construct()
    {
    parent::__construct();
    }

    function Category()
    {    
        parent::DataMapper();
    }
    
    function add()
    {
        
    $title = $this->input->post('title');
    echo $title;
    
    }
    
}
?>
#2

[eluser]Ben Edmunds[/eluser]
Inside the model you have to use get_object to get an instance of the CI super object.

So try:

Code:
$ci =& get_instance();
$title = $ci->input->post('title');
#3

[eluser]akzidenz[/eluser]
This is an awesome tip.
Thank you so much!
#4

[eluser]Federico Gonzalez[/eluser]
Hi, I had the same problem.. thanks Ben!




Theme © iAndrew 2016 - Forum software by © MyBB