commit 297e19d1a9af897892e788fe96df7af545a41976 Author: Brückner Tamás Date: Thu Sep 11 17:01:12 2014 +0200 Placeholder diff --git a/better_exposed_filters_exposed_form_plugin.inc b/better_exposed_filters_exposed_form_plugin.inc index cd87492..8e20cb9 100644 --- a/better_exposed_filters_exposed_form_plugin.inc +++ b/better_exposed_filters_exposed_form_plugin.inc @@ -500,6 +500,15 @@ Title Desc|Z -> A Leave the replacement value blank to remove an option al '#description' => t('Adds descriptive text to the exposed filter. This is usually rendered in smaller print under the label or the options.'), ); + // Build a placeholder option form element -- available to all exposed + // filters. + $bef_options[$label]['more_options']['bef_placeholder'] = array( + '#type' => 'textfield', + '#title' => t('Placeholder'), + '#default_value' => $existing[$label]['more_options']['bef_placeholder'], + '#description' => t('Adds placeholder HTML5 attribute for input element.'), + ); + // Add token support to the description field. $bef_options[$label]['more_options']['tokens'] = array( '#title' => t('Replacement patterns'), @@ -913,6 +922,24 @@ Title Desc|Z -> A Leave the replacement value blank to remove an option al $form[$field_id]['#bef_description'] = $options['more_options']['bef_filter_description']; } + // Token replacement on BEF placeholder. + if (!empty($options['more_options']['bef_placeholder'])) { + // Collect replacement data. + $data = array(); + $available = $options['more_options']['tokens']['available']; + if (in_array('vocabulary', $available)) { + $vocabs = taxonomy_get_vocabularies(); + $data['vocabulary'] = $vocabs[$filters[$label]->options['vid']]; + } + /* Others? */ + + // Replace tokens. + $options['more_options']['bef_placeholder'] = token_replace( + $options['more_options']['bef_placeholder'], $data + ); + $form[$field_id]['#placeholder'] = $options['more_options']['bef_placeholder']; + } + // Handle filter value rewrites. if (!empty($options['more_options']['rewrite']['filter_rewrite_values'])) { $lines = explode("\n", trim($options['more_options']['rewrite']['filter_rewrite_values']));