Hi,

i try to add programmatically a field in Views. I found this solution for a simple field:

function hook_views_pre_view(&$view, &$display_id, &$args) {
  if ($view->name == 'my_view') {
    $view->add_item($view->current_display, 'field', 'views', 'nothing', array(
      'label' => 'My field',
      'type'  => 'input',
      'alter' => array('text' => 'My field text'),
      'element_class' => 'my-field',
      'element_default_classes' => 0,
    ), 'my_field');
  }
}

This works fine for a simple field. But how can i add a simple imput form field to my view with this code? Can somebody help me?

Greetz Bavra

Comments

bavramor created an issue. See original summary.

MustangGB’s picture

Status: Active » Closed (outdated)

Closing this as outdated to tidy up a bit around here. If you're still having problems with the latest release please create a new issue.