I'm using Drupal 7 with views 3.
I am listing the student fees in a view and one of the field in view results is pid (payment id) which has some numeric value or NULL value. The NULL value means the payment is unpaid. I have used a custom field handler to show in view result as paid and unpaid for pid = some value as Paid and pid = Null value as Unpaid.
I want a filter on this field also which will have a drop down of two options as paid and unpaid. Which views filter I should use and how can I rename the drop down options?
hook_views_data()
// Status of payment paid or unpaid if pid is null in joined result set : unpaid
$data['fee_schedule_payments']['payment_status'] = array(
'real field' => 'pid',
'title' => t('Fee schedule payment status'),
'label' => t('Status'),
'help' => t('Fee schedule payment status'),
'field' => array(
'handler' => 'fee_management_handler_field_payment_status',
'click sortable' => TRUE, // This is use by the table display plugin.
),
'filter' => array(
'handler' => 'views_handler_filter_WHICH_ONE_I_SHOULD_USE',
),
);
class fee_management_handler_field_payment_status extends views_handler_field {
function construct() {
parent::construct();
$this->additional_fields['pid'] = 'pid';
}
function render($values) {
$pid = $this->get_value($values, 'pid');
if (!empty($pid)) {
return 'Paid';
}
return 'Unpaid';
}
};
Thanks in advance for your help.