⚠ 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

Bug v2.6.8: Custom dropdown field not working with callbackColumn



jw_hultafors
  • profile picture
  • Member

Posted 05 November 2018 - 11:13 AM

Hi,

 

Updated to 2.6.8 today and found that a bug has occured.

For fields using callbackColumn() and fieldType() at the same time does not seem to work (at least for FIELD_TYPE_DROPDOWN).

$crud->fieldType('compared_to_inv_no_diff', GroceryCrud::FIELD_TYPE_DROPDOWN, [
	1 => "No diff",
	0 => "With diff",
]);

$crud->callbackColumn('compared_to_inv_no_diff', function ($fieldValue, $primaryKeyValue) {
	return $this->__callbackBooleanNull($fieldValue, $primaryKeyValue);
});

protected function __callbackBooleanNull($fieldValue, $primaryKeyValue) {
	if ($fieldValue === null) {
		return "<i class=\"fa fa-question\"></i>";
	} else if ($fieldValue == 0) {
		return "<i class=\"fa fa-exclamation-triangle text-danger\"></i>";
	} else if ($fieldValue == 1) {
		return "<i class=\"fa fa-check text-success\"></i>";
	}
}

Any ideas?

Regards

Jonathan

 

EDIT: Should add that I'm using GCE with Laravel and MySQL. The field in the database is a nullable boolean field (TINYINT).


AndresSEGC
  • profile picture
  • Member

Posted 14 August 2019 - 14:51 PM

Hi, i have the same issue.

 

I want to do a callback and a dropdown for filter.

 

How can i do that? 

 

My code have a relation, so, how can i get the group description?

$crud->setRelation('group_id','groups','description');				
$crud->callbackColumn('group_id',array($this,'_crud_users_group'));
function _crud_users_group($value, $row)
{
	if($row->group_id == 1)
	{
		return "$value";
	}
	else if($row->group_id == 2)
	{
		return "$value <i class='fas fa-portrait' style='color:#348fe2'></i> <a href='".site_url('admin/asignar_clientes_jefe_equipo/edit/'.$row->user_id)."'>Asignar clientes</a>";
	}
	else if($row->group_id == 3)
	{
		return "$value";
	}
}