Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / form.twig
1 /**
2  * Implements hook_form().
3  */
4 function {{ machine_name }}_form($node, &$form_state) {
5   $type = node_type_get_type($node);
6
7   $form['title'] = array(
8     '#type' => 'textfield',
9     '#title' => check_plain($type->title_label),
10     '#default_value' => !empty($node->title) ? $node->title : '',
11     '#required' => TRUE, '#weight' => -5
12   );
13
14   $form['field1'] = array(
15     '#type' => 'textfield',
16     '#title' => t('Custom field'),
17     '#default_value' => $node->field1,
18     '#maxlength' => 127,
19   );
20   $form['selectbox'] = array(
21     '#type' => 'select',
22     '#title' => t('Select box'),
23     '#default_value' => $node->selectbox,
24     '#options' => array(
25       1 => 'Option A',
26       2 => 'Option B',
27       3 => 'Option C',
28     ),
29     '#description' => t('Choose an option.'),
30   );
31
32   return $form;
33 }