Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function MY_MODULE_form_process_user_picture(&$form, FormStateInterface &$form_state) {
- $file_name = "";
- $username = "";
- $fid_0 = NULL;
- $user_picture = $form['user_picture'];
- $uid = $form_state->getValue('uid');
- if ($form_state->hasFileElement() && $form_state->hasValue('user_picture')) {
- $username = $form_state->getValue('field_name')[0]['value'];
- $fid_0 = isset($form_state->getValue('user_picture')[0]['fids'][0]) ? $form_state->getValue('user_picture')[0]['fids'][0] : $fid_0;
- /*
- $changed = $form_state->get('user_picture')->getValue() == $form_state->getValue('user_picture');
- //This is not working as $form_state->get() returns null.
- */
- /*
- $changed = $form_state->get('user_picture')->getValue() == $form['user_picture']['#default_value'];
- //This is not working as $form['user_picture']['#default_value'] is null.
- */
- if($changed) {
- // Proceed to rename the file.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement