5 * Definition of views_handler_field_custom.
9 * A handler to provide a field that is completely custom by the administrator.
11 * @ingroup views_field_handlers
13 class views_handler_field_custom extends views_handler_field {
15 // do nothing -- to override the parent query.
18 function option_definition() {
19 $options = parent::option_definition();
21 // Override the alter text option to always alter the text.
22 $options['alter']['contains']['alter_text'] = array('default' => TRUE, 'bool' => TRUE);
23 $options['hide_alter_empty'] = array('default' => FALSE, 'bool' => TRUE);
27 function options_form(&$form, &$form_state) {
28 parent::options_form($form, $form_state);
30 // Remove the checkbox
31 unset($form['alter']['alter_text']);
32 unset($form['alter']['text']['#dependency']);
33 unset($form['alter']['text']['#process']);
34 unset($form['alter']['help']['#dependency']);
35 unset($form['alter']['help']['#process']);
36 $form['#pre_render'][] = 'views_handler_field_custom_pre_render_move_text';
39 function render($values) {
40 // Return the text, so the code never thinks the value is empty.
41 return $this->options['alter']['text'];
46 * Prerender function to move the textarea to the top.
48 function views_handler_field_custom_pre_render_move_text($form) {
49 $form['text'] = $form['alter']['text'];
50 $form['help'] = $form['alter']['help'];
51 unset($form['alter']['text']);
52 unset($form['alter']['help']);