|
@@ -30,6 +30,67 @@ function materio_user_form_user_login_form_alter(&$form, FormStateInterface $for
|
|
|
|
|
|
}
|
|
|
|
|
|
+function materio_user_form_user_modal_form_alter(&$form, FormStateInterface $form_state, $form_id) {
|
|
|
+ // Drupal::logger('materio_user')->notice(print_r($form['mail'], true));
|
|
|
+ // ksm($form);
|
|
|
+ $form['account']['mail']['#attributes'] = array(
|
|
|
+ "v-model" => "mail",
|
|
|
+ "@keyup.enter" => "register",
|
|
|
+ "placeholder" => $form['account']['mail']['#title'],
|
|
|
+ "title" => $form['account']['mail']['#description']
|
|
|
+ );
|
|
|
+
|
|
|
+ // https://drupal.stackexchange.com/a/217112
|
|
|
+ // Get default process function array:
|
|
|
+ $element_info = element_info('password_confirm');
|
|
|
+ $process = $element_info['#process'];
|
|
|
+ // Add our process function to the array:
|
|
|
+ $process[] = '_materio_user_process_password_confirm';
|
|
|
+ $form['account']['pass']['#process'] = $process;
|
|
|
+
|
|
|
+ $form['actions']['submit']['#attributes'] = array(
|
|
|
+ "@click.prevent" => "register",
|
|
|
+ "@keyup.enter" => "register"
|
|
|
+ );
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+function _materio_user_process_password_confirm($element){
|
|
|
+ // ksm($element);
|
|
|
+ $element['pass1']['#attributes'] += array(
|
|
|
+ "v-model" => "pass1",
|
|
|
+ "placeholder" => $element['pass1']['#title']
|
|
|
+ );
|
|
|
+ $element['pass2']['#attributes'] += array(
|
|
|
+ "v-model" => "pass2",
|
|
|
+ "placeholder" => $element['pass2']['#title']
|
|
|
+
|
|
|
+ );
|
|
|
+ return $element;
|
|
|
+}
|
|
|
+/**
|
|
|
+ * Returns HTML for a form element.
|
|
|
+ * Prepares variables for form element templates.
|
|
|
+ *
|
|
|
+ * Default template: form-element.html.twig.
|
|
|
+ *
|
|
|
+ * @param array $variables
|
|
|
+ * An associative array containing:
|
|
|
+ * - element: An associative array containing the properties of the element.
|
|
|
+ * Properties used: #title, #title_display, #description, #id, #required,
|
|
|
+ * #children, #type, #name, #label_for.
|
|
|
+ */
|
|
|
+// function materio_user_preprocess_form_element(&$vars) {
|
|
|
+// $element = $vars['element'];
|
|
|
+// if($element['#type'] == 'password' && $element['#array_parents'][0] == 'account'){
|
|
|
+// ksm($vars);
|
|
|
+// // $vars['attributes']['placeholder'] = $element['#title'];
|
|
|
+// $vars['element']['#attributes']['placeholder'] = $element['#title'];
|
|
|
+// }
|
|
|
+// }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
* implements hook_block_view_BASE_BLOCK_ID_alter()
|
|
|
*
|
|
@@ -55,3 +116,8 @@ function _materio_user_user_login_block_pre_render(array $build){
|
|
|
));
|
|
|
return $build;
|
|
|
}
|
|
|
+
|
|
|
+function materio_user_entity_type_build(array &$entity_types) {
|
|
|
+ // https://drupal.stackexchange.com/a/230547
|
|
|
+ $entity_types['user']->setFormClass('modal', 'Drupal\user\RegisterForm');
|
|
|
+}
|