You are here

function _password_field_load_current_value in Password Field 7

Load field value.

Given an element and form state, load the current value of the field instance.

1 call to _password_field_load_current_value()
_password_field_encrypt in ./password_field.module
Encrypt the password.

File

./password_field.module, line 178
Password Field Module

Code

function _password_field_load_current_value($element, $form_state) {

  // Get field details.
  $field_details = _password_field_get_instance_details($element, $form_state);
  $entity_type = $field_details['entity_type'];

  // If there is no entity, then there can't be a value.
  if (empty($form_state[$entity_type])) {
    return;
  }
  $entity = $form_state[$entity_type];
  $field_name = $field_details['field_name'];
  $delta = $field_details['delta'];

  // Load the field instance from DB and get the value.
  $pwfield = field_get_items($entity_type, $entity, $field_name);
  $pwvalue = isset($pwfield[$delta]['password_field']) ? $pwfield[$delta]['password_field'] : NULL;
  return $pwvalue;
}