Concrete example of an exposed Boolean filter for a view on a custom entity. Note that I had to add _value
to field names.
- Custom module name:
rsc
- View machine name:
transactions
- Page machine name:
purchase
- Field name:
field_order_shipped
Actual code:
function rsc_form_views_exposed_form_alter(&$form, &$form_state)
{
if ($form['#id'] == 'views-exposed-form-transactions-purchase') {
$form['field_order_shipped_value']['#options']['All'] = 'Any';
$form['field_order_shipped_value']['#options']['1'] = 'Yes';
$form['field_order_shipped_value']['#options']['0'] = 'No';
}
}