Заставьте модуль "юридический" отображать "ошибку набора формы" на пути/пользователе/регистрации
Я использую "юридический" модуль версии 6.x-8.5.
Это отличный модуль, но я думаю, что необходимо сообщение form_set_error()
, чтобы показать пользователю, который пытается зарегистрироваться, почему регистрация не может быть применена, если он забудет установить необходимый флажок(флажки).
Я ищу возможность заставить это работать.
Кто-нибудь знает, где реализовать эту функцию (жестко запрограммированную, если нет другого решения) в модуле?
Я также пытался сделать это с помощью форм правил, с помощью этого правило:
array (
'rules' =>
array (
'rules_register_ckeck_agb' =>
array (
'#type' => 'rule',
'#set' => 'event_user_register_form_validate',
'#label' => 'Register ckeck AGB',
'#active' => 0,
'#weight' => '0',
'#categories' =>
array (
),
'#status' => 'custom',
'#conditions' =>
array (
0 =>
array (
'#settings' =>
array (
'element' => 'legal[legal_accept]',
'value' => '1',
'#argument map' =>
array (
'form' => 'form',
'form_state' => 'form_state',
),
),
'#type' => 'condition',
'#name' => 'rules_forms_condition_element_value',
'#info' =>
array (
'label' => 'Form element \'legal[legal_accept]\' value check',
'arguments' =>
array (
'form' =>
array (
'type' => 'form',
'label' => 'Formular',
),
'form_state' =>
array (
'type' => 'form_state',
'label' => 'Form state',
),
'element' =>
array (
'type' => 'string',
'label' => 'Form element ID',
'description' => 'ID of the form element to be targeted. Examples on the "Create Story" form: "title" for the title field or "body_field[body]" for the body field.',
),
'value' =>
array (
'type' => 'string',
'label' => 'Value(s)',
'description' => 'Value(s) assigned to the form element. If the form element allows multiple values, enter one value per line.',
),
),
'module' => 'Rules Forms',
),
'#weight' => 0,
'#negate' => 1,
),
),
'#actions' =>
array (
0 =>
array (
'#weight' => 0,
'#info' =>
array (
'label' => 'Set form error on element \'legal[legal_accept]\'',
'arguments' =>
array (
'form' =>
array (
'type' => 'form',
'label' => 'Formular',
),
'element' =>
array (
'type' => 'string',
'label' => 'Form element ID',
'description' => 'The element that should be marked. Examples on the "Create Story" form: "title" for the title field or "body_field[body]" for the body field.',
),
'message' =>
array (
'type' => 'string',
'label' => 'Nachricht',
'description' => 'The message that should be displayed to the user.',
),
),
'module' => 'Rules Forms',
),
'#name' => 'rules_forms_action_set_error',
'#settings' =>
array (
'element' => 'legal[legal_accept]',
'message' => 'Please Confirm the...',
'#argument map' =>
array (
'form' => 'form',
),
),
'#type' => 'action',
),
),
'#version' => 6003,
),
),
)
Но это тоже не та работа, которую он должен выполнять. Кто-нибудь знает, что я, возможно, делаю здесь неправильно? Спасибо за все ваши предложения. с уважением деннис605
1 answers
Я опубликовал свой ответ на вашу проблему в юридическом вопросе, который вы создали.
Я расскажу, как вы создадите дополнительную проверку, которая вызовет form_set_error()
Создайте пользовательский модуль с помощью этого
function example_form_alter(&$form, &$form_state, $form_id) {
if($form_id == 'user_register') {
$form['legal']['legal_accept']['#element_validate'] = array('_example_custom_field_validate');
}
}
function _example_custom_field_validate($element, &$form_state) {
if (empty($element['#value'])) {
form_error($element, t('This is my custom message if `Terms & Conditions` is not checked off.'));
}
}
Если вы не видите сообщение сейчас, я беспокоюсь, что у вас отключены сообщения об ошибках.