function angularjs_examples_nodes_list_form_builder in AngularJS 7
1 string reference to 'angularjs_examples_nodes_list_form_builder'
- angularjs_examples_nodes_list in modules/
angularjs_examples/ angularjs_examples.module - Menu callback for node list template
File
- modules/
angularjs_examples/ angularjs_examples.module, line 34
Code
function angularjs_examples_nodes_list_form_builder($form, &$form_state) {
$options = node_type_get_names();
$form['node_type'] = array(
'#type' => 'ng_select',
'#title' => t('Content type'),
'#options' => $options,
'#description' => t('Filter by content-type.'),
'#default_value' => key($options),
// Define the ng-model and controller.
'#ng_model' => 'nodeType',
'#ng_controller' => 'ListCtrl',
// Add ng-change.
'#attributes' => array(
'ng-change' => 'filterNodeType()',
),
);
$form['title'] = array(
'#type' => 'textfield',
'#title' => t('Title'),
'#attributes' => array(
'ng-model' => 'query.title',
'placeholder' => t('Filter by title'),
// HTML5 attribute to Prevent from autocomplete to hide our table.
'autocomplete' => 'off',
),
'#ng_controller' => 'ListCtrl',
);
$header = array(
t('Title'),
t('Author'),
);
$row = array(
'{{node.title}}',
'{{node.author.id}}',
);
$form['table'] = array(
'#theme' => 'ng_table',
'#header' => $header,
'#row' => $row,
'#empty' => t('No content found.'),
// Optionally filter query.
'#ng_repeat' => 'node in nodes.list | filter: query',
// Used for the empty text.
'#ng_model' => 'nodes.list',
// Empty text logic.
'#ng_empty' => '(nodes.list | filter: query).length == 0',
);
return $form;
}