Jump to content


Passing values to field_type hidden from $_SESSION

$_SESSION field_type passing values

  • Please log in to reply
1 reply to this topic

#1 kolo78

kolo78

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationBuenos Aires, Argentina

Posted 16 June 2018 - 06:39 PM

Hello Everybody, 

 

I'm struggling with a problem, I tried several ways to accomplish this with no lucky.

 

I need to pass a value: tbl_asegurado_fenixid to the add form. I have this value already saved in a $_Session ... but don't know why isn't populate on the DB...

 

This is my code,

public function index()
    {
    	$this->global['pageTitle'] = 'Fenix : Mis Fenix';
	    $fenixidget =$this->input->get('fenixid');

	    $this->session->set_userdata('fenixid', $fenixidget);

	    echo $_SESSION['fenixid'];

       $this->cargarasegurados();

    }

	public function cargarasegurados()
	{
		$crud = new grocery_CRUD();
		echo $id_insertar;
		$crud->set_theme('datatables');
		$crud->set_table('asegurado');
		$crud->set_subject('Asegurados');

		//$crud->unset_add();
		$crud->unset_clone();
		$crud->unset_delete();
		$crud->unset_export();
		$crud->unset_print();

		$crud->columns('tbl_asegurado_fenixid','tbl_asegurado_nombre',
						'tbl_asegurado_dni','tbl_asegurado_catastro','tbl_asegurado_telefono');

		$crud->fields('tbl_asegurado_fenixid','tbl_asegurado_nombre',
			'tbl_asegurado_dni','tbl_asegurado_catastro','tbl_asegurado_telefono');

		$crud->field_type('tbl_asegurado_fenixid', 'hidden', $_SESSION['fenixid']);

		//$crud->display_as('tbl_asegurado_fenixid','Fenix_ID');

		$crud->where('tbl_asegurado_fenixid', $_SESSION['fenixid']);

		$output = $crud->render();
		$this->global['pageTitle'] = 'Fenix : Asegurados';

		$this->loadViews("asegurados",$this->global,$output,"NULL");


	}

The session is working fine for the WHERE condition.

 

Any help will be higly appreciated!

 

Regards,

Pablo

 

--- Added Information ---

 

I've also tried with the following code

$crud->callback_add_field('tbl_asegurado_fenixid',function(){
			return '<input type="text" maxlength="50" value="'. $_SESSION['fenixid']  .'" name="tbl_asegurado_fenixid
">';


		});


#2 kolo78

kolo78

    Newbie

  • Members
  • Pip
  • 5 posts
  • LocationBuenos Aires, Argentina

Posted 16 June 2018 - 07:20 PM

Problem solved, in case someone else experienced the same issue:

if (isset( $_GET['fenixid']))
    	{
		    $fenixidget =$this->input->get('fenixid');

		    $this->session->set_userdata('fenixid', $fenixidget);

		    echo $_SESSION['fenixid'];
	    }

This need to be done, to avoid the controller to overwrite the session variable with NULL







Also tagged with one or more of these keywords: $_SESSION, field_type, passing values

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users