public function FloatingSocialIconsBlock::blockValidate in Floating Social Icons 8
Overrides BlockPluginTrait::blockValidate
File
- src/
Plugin/ Block/ FloatingSocialIconsBlock.php, line 352
Class
- FloatingSocialIconsBlock
- Provides a 'Floating Social Icon' Block.
Namespace
Drupal\floating_social_icons\Plugin\BlockCode
public function blockValidate($form, FormStateInterface $form_state) {
$values = $form_state
->getValues();
$links = [];
$links[] = $values['floating_facebook']['facebook_link'];
$links[] = $values['floating_twitter']['twitter_link'];
$links[] = $values['floating_google_plus']['google_plus_link'];
$links[] = $values['floating_linkedIn']['linkedIn_link'];
$links[] = $values['floating_pinterest']['pinterest_link'];
$links[] = $values['floating_instagram']['instagram_link'];
$links[] = $values['floating_mail']['mail_link'];
$links[] = $values['floating_youtube']['youtube_link'];
$count = 0;
if ($links) {
foreach ($links as $link) {
if (!empty($link)) {
$count = $count + 1;
}
}
}
if ($count < 2) {
$form_state
->setErrorByName('floatingsocialblock', $this
->t('At least two fields should be filled.'));
}
// Setting count value.
$this->configuration['count'] = $count;
}