Skip to content

Instantly share code, notes, and snippets.

@JeromeChevalier
Last active November 18, 2018 22:35
Show Gist options
  • Save JeromeChevalier/d2f36463796e042641d69b35ee1cfef9 to your computer and use it in GitHub Desktop.
Save JeromeChevalier/d2f36463796e042641d69b35ee1cfef9 to your computer and use it in GitHub Desktop.
Render Array template #drupal8
// Test Field
$render['myTextField'] = [
'#type' => 'textfield',
'#title' => t('My title'),
];
// Number Field
$render['myNumberField'] = [
'#type' => 'number',
'#min' => '0',
'#max' => '100',
'#step' => '1',
'#size' => '9',
'#title' => t('My title'),
];
// Link with button aspect
$render['myButton'] = [
'#type' => 'link',
'#title' => t('MyTitle'),
'#url' => \Drupal\Core\Url::fromUserInput('/myPath'),
];
$render['myButton']['#attributes']['class'][] = 'ui green button';
// Select
$render['mySelect'] = array(
'#type' => 'select',
'#title' => $this->t("myTitle"),
'#options' => [
'1' => $this->t("option1"),
'2' => $this->t("option2"),
'3' => $this->t("option3"),
],
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment