Как получить Нид Ноды находясь в _form_validation_number_title_validate?
<?php
// I want to add some more light on this matter.
// The adding of the validation is exactly the same as before:
// in hook_form_alter:
...
$form['#validate'][] = '_form_validation_number_title_validate';
...
// The use of the values object inside of the $form_state in the
// validate function is though a bit different. e.g.:
function _form_validation_number_title_validate(&$form, \Drupal\Core\Form\FormStateInterface $form_state) {
// здесь нужна $node->nid !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
if (
$form_state->hasValue('title')) {
$title = $form_state->getValue('title');
if (!
is_numeric($title[0]['value'])) {
$form_state->setErrorByName('title', t('Your title should be number'));
}
}
}
?>
Спасибо
Комментарии
Настроить уже xdebug и заглянуть в содержимое $form_state, например