Markup kits¶
Kits in src/Kits/Markup/ that output content rather than inputs.
MarkupKit¶
A markup element. The markup is filtered by core's XSS admin filter when rendered.
| Class | Drupal\formfactorykits\Kits\Markup\MarkupKit (src/Kits/Markup/MarkupKit.php) |
| Extends | FormFactoryKit |
| Factory method | $kits->markup() |
Form API #type |
markup |
| Default ID | markup |
| Traits | none |
Setters
| Method | From |
|---|---|
setMarkup(string $markup) |
MarkupKit |
Example
$kit = $kits->markup('intro')->setMarkup('<p>Welcome.</p>');
Generated render array ([$kit->getID() => $kit->getArray()])
[
'intro' => [
'#type' => 'markup',
'#markup' => '<p>Welcome.</p>',
],
]
TextKit¶
A markup element for plain text: setValue() strips HTML tags. This is what $kits->text() returns; it is not a text input (use textField() for that).
| Class | Drupal\formfactorykits\Kits\Markup\TextKit (src/Kits/Markup/TextKit.php) |
| Extends | MarkupKit |
| Factory method | $kits->text() |
Form API #type |
markup |
| Default ID | text |
| Traits | none |
Setters
| Method | From |
|---|---|
setMarkup(string $markup) |
MarkupKit |
setValue(string $value) |
TextKit |
Example
$kit = $kits->text('note')->setValue('<b>Plain</b> text');
Generated render array ([$kit->getID() => $kit->getArray()])
[
'note' => [
'#type' => 'markup',
'#markup' => 'Plain text',
],
]
HeadingKit¶
A markup element containing an <hN> heading. The text and level are kept in context and turned into #markup when built; level defaults to 1.
| Class | Drupal\formfactorykits\Kits\Markup\HeadingKit (src/Kits/Markup/HeadingKit.php) |
| Extends | MarkupKit |
| Factory method | $kits->heading() |
Form API #type |
markup |
| Default ID | heading |
| Traits | none |
Setters
| Method | From |
|---|---|
setMarkup(string $markup) |
MarkupKit |
setNumber(int $number) |
HeadingKit |
setValue(string $value) |
HeadingKit |
Example
$kit = $kits->heading('title')->setValue('Settings')->setNumber(2);
Generated render array ([$kit->getID() => $kit->getArray()])
[
'title' => [
'#type' => 'markup',
'#markup' => '<h2>Settings</h2>',
],
]
ItemKit¶
An item element with #markup (a labelled, read-only value). It has no default #type, so pass ['type' => 'item'] in $parameters if you want one.
| Class | Drupal\formfactorykits\Kits\Markup\ItemKit (src/Kits/Markup/ItemKit.php) |
| Extends | FormFactoryKit |
| Factory method | $kits->item() |
Form API #type |
none |
| Default ID | item |
| Traits | none |
Setters
| Method | From |
|---|---|
setMarkup(string $markup) |
ItemKit |
Example
$kit = $kits->item('version', ['type' => 'item', 'title' => 'Version'])->setMarkup('2.1');
Generated render array ([$kit->getID() => $kit->getArray()])
[
'version' => [
'#type' => 'item',
'#title' => 'Version',
'#markup' => '2.1',
],
]
TemplateKit¶
An inline_template element. Variables set with setTemplateContext() become #context. setTemplateFile() reads the template from a file.
| Class | Drupal\formfactorykits\Kits\Markup\TemplateKit (src/Kits/Markup/TemplateKit.php) |
| Extends | FormFactoryKit |
| Factory method | $kits->template() |
Form API #type |
inline_template |
| Default ID | inline_template |
| Traits | none |
Setters
| Method | From |
|---|---|
setTemplate(string $template) |
TemplateKit |
setTemplateContext(string $key, string $value) |
TemplateKit |
setTemplateFile(string $filename) |
TemplateKit |
Example
$kit = $kits->template('hello')->setTemplate('<p>Hello {{ name }}</p>')->setTemplateContext('name', 'Ada');
Generated render array ([$kit->getID() => $kit->getArray()])
[
'hello' => [
'#type' => 'inline_template',
'#template' => '<p>Hello {{ name }}</p>',
'#context' => [
'name' => 'Ada',
],
],
]
ExampleKit¶
A TemplateKit that shows a code example in <pre>, with an optional bold title (set as #prefix).
| Class | Drupal\formfactorykits\Kits\Markup\ExampleKit (src/Kits/Markup/ExampleKit.php) |
| Extends | TemplateKit |
| Factory method | $kits->example() |
Form API #type |
inline_template |
| Default ID | inline_template |
| Traits | PrefixTrait, SuffixTrait |
Setters
| Method | From |
|---|---|
setExample(string $example) |
ExampleKit |
setPrefix(array\|string\|null $value) |
PrefixTrait (trait) |
setSuffix(array\|string\|null $value) |
SuffixTrait (trait) |
setTemplate(string $template) |
TemplateKit |
setTemplateContext(string $key, string $value) |
TemplateKit |
setTemplateFile(string $filename) |
TemplateKit |
setTitle($title) |
ExampleKit |
Example
$kit = $kits->example('demo')->setTitle('Usage')->setExample('$kits->submit()');
Generated render array ([$kit->getID() => $kit->getArray()])
[
'demo' => [
'#type' => 'inline_template',
'#template' => '<pre>{{ example }}</pre>',
'#prefix' => '<div><strong>Usage</strong></div>',
'#context' => [
'example' => '$kits->submit()',
],
],
]