I'm working with codeigniter
. When submitting a form I am sending the data to model
through getters and setters.
This is my input
div class="col-md-6">
<div class="form-group">
<?php echo form_label('Fornecedores (CNPJ - Razão Social):*', 'fornecedor'); ?>
<?php echo form_dropdown('fornecedor', $fornecedores, set_value('fornecedor'), array("class" => 'form-control', 'required' => 'required'))?>
</div>
</div>
When you click submit, enter a method in the controller that has this code:
$this->load->model('Movimento_model', 'movimento');
$this->movimento->setCnpj($this->input->post('fornecedor'));
echo $this->movimento->getCnpj(); // exibe para teste
This is my model (summarized):
class Movimento_model extends CI_Model {
private $cnpj;
public function setCnpj($cnpj)
{
$this->cnpj = strtoupper(trim($cnpj));
}
public function getCnpj()
{
return $this->$cnpj; // LINHA DO ERRO
}
This is the error:
Undefined variable: cnpj
Note: I'm setting but it seems that it is not accepting. When I try to show the error occurs.