public function BlazyAdminExtended::fieldableForm in Blazy 7
Returns re-usable fieldable formatter form elements.
File
- src/
Form/ BlazyAdminExtended.php, line 50
Class
- BlazyAdminExtended
- Provides re-usable admin functions, or form elements.
Namespace
Drupal\blazy\FormCode
public function fieldableForm(array &$form, $definition = []) {
if (isset($definition['images'])) {
$form['image'] = [
'#type' => 'select',
'#title' => t('Main stage'),
'#options' => is_array($definition['images']) ? $definition['images'] : [],
'#description' => t('Main background/stage image field. To have a mix of image and video with hires images, be sure to provide the same image field for both image and video. Leave empty to use default thumbnail if video, or just image.'),
'#prefix' => '<h3 class="form__title form__title--fields">' . t('Fields') . '</h3>',
];
}
if (isset($definition['thumbnails'])) {
$form['thumbnail'] = [
'#type' => 'select',
'#title' => t('Thumbnail image'),
'#options' => is_array($definition['thumbnails']) ? $definition['thumbnails'] : [],
'#description' => t('Leave empty to not use thumbnail pager.'),
];
}
if (isset($definition['overlays'])) {
$form['overlay'] = [
'#type' => 'select',
'#title' => t('Overlay media'),
'#options' => is_array($definition['overlays']) ? $definition['overlays'] : [],
'#description' => t('Overlay is displayed over the main stage.'),
];
}
if (isset($definition['titles'])) {
$form['title'] = [
'#type' => 'select',
'#title' => t('Title'),
'#options' => is_array($definition['titles']) ? $definition['titles'] : [],
'#description' => t('If provided, it will bre wrapped with H2.'),
];
}
if (isset($definition['links'])) {
$form['link'] = [
'#type' => 'select',
'#title' => t('Link'),
'#options' => is_array($definition['links']) ? $definition['links'] : [],
'#description' => t('Link to content: Read more, View Case Study, etc.'),
];
}
if (isset($definition['classes'])) {
$form['class'] = [
'#type' => 'select',
'#title' => t('Item class'),
'#options' => is_array($definition['classes']) ? $definition['classes'] : [],
'#description' => t('If provided, individual item will have this class, e.g.: to have different background with transparent images. Be sure its formatter is Key or Label. Accepted field types: list text, string (e.g.: node title), term/entity reference label.'),
'#weight' => 6,
];
}
if (!empty($definition['id'])) {
$form['id'] = [
'#type' => 'textfield',
'#title' => t('@namespace ID', [
'@namespace' => $definition['namespace'],
]),
'#size' => 40,
'#maxlength' => 255,
'#field_prefix' => '#',
'#enforced' => TRUE,
'#description' => t("Manually define the container ID. <em>This ID is used for the cache identifier, so be sure it is unique</em>. Leave empty to have a guaranteed unique ID managed by the module."),
'#weight' => 94,
];
}
if (isset($form['caption'])) {
$form['caption']['#description'] = t('Enable any of the following fields as captions. These fields are treated and wrapped as captions.');
}
if (empty($definition['id'])) {
if (isset($form['caption'])) {
$form['caption']['#description'] .= ' ' . t('Be sure to make them visible at their relevant Manage display.');
}
}
else {
if (isset($form['overlay'])) {
$form['overlay']['#description'] .= ' ' . t('Be sure to CHECK "Use field template" under its formatter if using Slick field formatter.');
}
}
}