public function Masonry::buildOptionsForm in Masonry Views 8
Provide a form to edit options for this plugin.
Overrides StylePluginBase::buildOptionsForm
File
- src/
Plugin/ views/ style/ Masonry.php, line 77 - Contains \Drupal\masonry_views\Plugin\views\style\Masonry.
Class
- Masonry
- Style plugin to render each item in a Masonry Layout.
Namespace
Drupal\masonry_views\Plugin\views\styleCode
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
// Add Masonry options to views form.
$form['masonry'] = [
'#type' => 'details',
'#title' => $this
->t('Masonry'),
'#open' => TRUE,
];
if (\Drupal::service('masonry.service')
->isMasonryInstalled()) {
$form += \Drupal::service('masonry.service')
->buildSettingsForm($this->options);
// Display each option within the Masonry fieldset.
foreach (\Drupal::service('masonry.service')
->getMasonryDefaultOptions() as $option => $default_value) {
$form[$option]['#fieldset'] = 'masonry';
}
// Views doesn't use FAPI states, so set dependencies instead.
$form['masonry_animated']['#dependency'] = [
'edit-style-options-masonry-resizable' => [
1,
],
];
$form['masonry_animation_duration']['#dependency'] = [
'edit-style-options-masonry-animated' => [
1,
],
];
}
else {
// Disable Masonry as plugin is not installed.
$form['masonry_disabled'] = [
'#markup' => $this
->t('These options have been disabled as the jQuery Masonry plugin is not installed.'),
'#fieldset' => 'masonry',
];
}
}