SHARE
TWEET

Untitled

a guest Feb 20th, 2019 48 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function MY_MODULE_form_process_user_picture(&$form, FormStateInterface &$form_state) {
  2.   $file_name = "";
  3.   $username = "";
  4.   $fid_0 = NULL;
  5.   $user_picture = $form['user_picture'];
  6.   $uid = $form_state->getValue('uid');
  7.   if ($form_state->hasFileElement() && $form_state->hasValue('user_picture')) {
  8.     $username = $form_state->getValue('field_name')[0]['value'];
  9.     $fid_0 = isset($form_state->getValue('user_picture')[0]['fids'][0]) ? $form_state->getValue('user_picture')[0]['fids'][0] : $fid_0;
  10.     /*
  11.       $changed = $form_state->get('user_picture')->getValue() == $form_state->getValue('user_picture');
  12.       //This is not working as $form_state->get() returns null.
  13.     */
  14.     /*
  15.       $changed = $form_state->get('user_picture')->getValue() == $form['user_picture']['#default_value'];
  16.       //This is not working as $form['user_picture']['#default_value'] is null.
  17.     */
  18.       if($changed) {
  19.         // Proceed to rename the file.
  20.       }
  21.     }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top