Skip to content
Snippets Groups Projects

Issue #3417468: Add message about missing styles for Style Form

@@ -5,6 +5,7 @@ namespace Drupal\paragraphs_gridstack\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
use Drupal\paragraphs_gridstack\GridstackBreakpointsManagerInterface;
use Drupal\paragraphs_gridstack\GridstackStylesManager;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -113,12 +114,39 @@ class ParagraphsGridstackManageStyles extends EntityForm {
$options_list[$option['class']] = $option['name'];
}
$form['options'] = [
'#type' => 'select',
'#title' => $this->t('Choose style options'),
'#options' => $options_list,
'#description' => $this->t('What options you choose?'),
];
if (empty($options_list)) {
$form['missing_styles_message'] = [
'#type' => 'container',
'#weight' => -100,
'#attributes' => [
'class' => ['gridstack-missing-styles-message'],
],
];
$form['missing_styles_message']['message_text'] = [
'#type' => 'html_tag',
'#tag' => 'span',
'#value' => t('Missing style options, please set it for the:'),
'#attributes' => [
'class' => ['gridstack-missing-styles-message-link'],
],
];
$form['missing_styles_message']['message_link'] = [
'#title' => 'Gridstack Optionset',
'#type' => 'link',
'#url' => Url::fromRoute('entity.paragraphs_gridstack.edit_form', ['paragraphs_gridstack' => $this->getEntity()->id()]),
'#attributes' => [
'class' => ['gridstack-missing-styles-message-link'],
],
];
}
else {
$form['options'] = [
'#type' => 'select',
'#title' => $this->t('Choose style options'),
'#options' => $options_list,
'#description' => $this->t('What options you choose?'),
];
}
// Return the form.
return $form;
Loading