By mrweiner on
I have a custom module that I'm using to change a text views exposed filter into checkboxes. I thought that it was working and the Warning was harmless, but apparently it isn't actually functioning correctly.
Warning: addcslashes() expects parameter 1 to be string, array given in DatabaseConnection->escapeLike() (line 965 of /Applications/MAMP/htdocs/includes/database/database.inc).
The code for the module is:
<?php
function dropdown_bartab_form_views_exposed_form_alter(&$form, &$form_state) {
$field_id = 'field_venue_bar_tab';
// Only alter forms with the necessary field
if (isset($form[$field_id .'_value'])) {
// Build a query to get all node ids having the specified field
$query = new EntityFieldQuery();
$results = $query->entityCondition('entity_type', 'node')
->fieldCondition($field_id, 'value', 'NULL', '!=')
->fieldOrderBy($field_id, 'value', 'ASC')
->execute();
// Attach the field values to the nodes
$nodes = $results['node'];
field_attach_load('node', $nodes, FIELD_LOAD_CURRENT, array('field_id' => $field_id));
// Add a default so the filter is optional
$options = array(
'Food' => 'Food',
'Drinks' => 'Drinks',
);
// Alter the field
$form[$field_id .'_value']['#type'] = 'checkboxes';
$form[$field_id .'_value']['#options'] = $options;
}
}
Any ideas?
Comments
First you need to figure out
First you need to figure out what line of code is causing your troubles. Comment out the lines until you figure out which one it is.
Contact me to contract me for D7 -> D10/11 migrations.