Jump to content


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

bug dropdown callback column

  • Please log in to reply
1 reply to this topic

#1 jw_hultafors

jw_hultafors

    Newbie

  • Members
  • Pip
  • 1 posts

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).



#2 AndresSEGC

AndresSEGC

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 14 August 2019 - 02: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";
	}
}






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users