public function TrumbaBlockBase::blockValidate in Trumba 8
Same name and namespace in other branches
- 2.x src/Plugin/Block/TrumbaBlockBase.php \Drupal\trumba\Plugin\Block\TrumbaBlockBase::blockValidate()
Overrides BlockPluginTrait::blockValidate
File
- src/
Plugin/ Block/ TrumbaBlockBase.php, line 116
Class
- TrumbaBlockBase
- Defines a base block implementation that Trumba blocks plugins will extend.
Namespace
Drupal\trumba\Plugin\BlockCode
public function blockValidate($form, FormStateInterface $form_state) {
// Ensure that internal url's start with a forward slash.
$rawUrl = $form_state
->getValue('trumba_spud_url');
$firstChar = substr($rawUrl, 0, 1);
if (!empty($rawUrl) && !$this
->isExternalUri($rawUrl) && $firstChar != '/') {
$form_state
->setErrorByName('trumba_spud_url', $this
->t('Internal Url\'s must begin with a forward slash.'));
}
}