By editor, 10 December, 2015 Set the page title programmatically in Drupal 9 Tags Drupal 8 Code Drupal 9 Change on a form or controller Just set ['#title'] element. Form Example : $form['#title'] = "The title";
By editor, 9 December, 2015 Login programmatically as a user Tags Drupal 8 Code User Example: $user = User::load($uid); user_login_finalize($user);
By editor, 9 December, 2015 Get all user's roles Tags Drupal 8 User Code Get All roles: $roles = \Drupal\user\Entity\Role::loadMultiple();
By editor, 8 December, 2015 Form API Error - illegal selection Tags Drupal 8 Form Code Most likely, this error is due to dynamicaly changed options list. If you want to change the values of the options list, You must add: '#validated' => TRUE
By editor, 8 December, 2015 Database LIKE condition Tags Drupal 8 Database Code The like condition syntax is: $query->condition('field_name', "%" . $query->escapeLike("The string") . "%", 'LIKE'); Example: