annotate vendor/chi-teck/drupal-code-generator/templates/d7/hook/form.twig @ 5:12f9dff5fda9
tip
Update to Drupal core 8.7.1
author |
Chris Cannam |
date |
Thu, 09 May 2019 15:34:47 +0100 |
parents |
c75dbcec494b |
children |
|
rev |
line source |
Chris@0
|
1 /**
|
Chris@0
|
2 * Implements hook_form().
|
Chris@0
|
3 */
|
Chris@0
|
4 function {{ machine_name }}_form($node, &$form_state) {
|
Chris@0
|
5 $type = node_type_get_type($node);
|
Chris@0
|
6
|
Chris@0
|
7 $form['title'] = array(
|
Chris@0
|
8 '#type' => 'textfield',
|
Chris@0
|
9 '#title' => check_plain($type->title_label),
|
Chris@0
|
10 '#default_value' => !empty($node->title) ? $node->title : '',
|
Chris@0
|
11 '#required' => TRUE, '#weight' => -5
|
Chris@0
|
12 );
|
Chris@0
|
13
|
Chris@0
|
14 $form['field1'] = array(
|
Chris@0
|
15 '#type' => 'textfield',
|
Chris@0
|
16 '#title' => t('Custom field'),
|
Chris@0
|
17 '#default_value' => $node->field1,
|
Chris@0
|
18 '#maxlength' => 127,
|
Chris@0
|
19 );
|
Chris@0
|
20 $form['selectbox'] = array(
|
Chris@0
|
21 '#type' => 'select',
|
Chris@0
|
22 '#title' => t('Select box'),
|
Chris@0
|
23 '#default_value' => $node->selectbox,
|
Chris@0
|
24 '#options' => array(
|
Chris@0
|
25 1 => 'Option A',
|
Chris@0
|
26 2 => 'Option B',
|
Chris@0
|
27 3 => 'Option C',
|
Chris@0
|
28 ),
|
Chris@0
|
29 '#description' => t('Choose an option.'),
|
Chris@0
|
30 );
|
Chris@0
|
31
|
Chris@0
|
32 return $form;
|
Chris@0
|
33 }
|