Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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
Comment #2
MustangGB CreditAttribution: MustangGB commentedClosing 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.