⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

getState - record not saved proerly



markyie
  • profile picture
  • Member

Posted 01 June 2016 - 01:07 AM

hi, i'm new here.. this is my first issue using GC.

 

below are the code in controller.

	public function trxgroup()
	{
		$crud = $this->generate_crud('ref_genlookups');
		$crud -> where('lookup_group_code','TRXGRP');
		$crud -> columns('code', 'description');
		$crud->set_relation('data_owner','users','username');

		$crud->field_type('active', 'hidden', 1);
		$crud->field_type('lookup_group_code', 'hidden', 'TRXGRP');

		$crud->field_type('deleted', 'hidden');
		$crud->field_type('deletedby', 'hidden');

		$date = date('Y-m-d H:i:s');
		
		$state = $crud->getState();
		if ($state==='add')
		{
			$crud->field_type('created', 'hidden', $date);
			$crud->field_type('createdby', 'hidden', $this->mUser->id);
			$crud->field_type('updated', 'hidden');
			$crud->field_type('updatedby', 'hidden');
		}else{
			$crud->field_type('created', 'readonly');
			$crud->field_type('createdby', 'readonly');
			$crud->field_type('updated', 'hidden', $date);
			$crud->field_type('updatedby', 'hidden', $this->mUser->id);
		}

		$this->mTitle.= 'Transaction Group';
		$this->render_crud();
	}

the problem is on created field. I didn't save the $date value.

datatype for the field id DATETIME.

 

Appreciate your help guys.

Thanks.


markyie
  • profile picture
  • Member

Posted 01 June 2016 - 01:12 AM

sorry for typo title guys.. should be "properly" not "proerly"