function _password_field_get_instance_details in Password Field 7
Get field instance details.
Given an element and form state, load details of the field instance and the entity type it is attached to.
1 call to _password_field_get_instance_details()
- _password_field_load_current_value in ./
password_field.module - Load field value.
File
- ./
password_field.module, line 151 - Password Field Module
Code
function _password_field_get_instance_details($element, $form_state) {
// Parse the element name to determine field name, language, and delta.
$pattern = '/^([^\\[]+)\\[([^\\[]+)]\\[([^\\[]+)\\]/';
if (!preg_match($pattern, $element['#name'], $matches)) {
return;
}
list($full_match, $field_name, $langcode, $delta) = $matches;
// Get the entity type and the entity itself.
$field_instance = $form_state['field'][$field_name][$langcode]['instance'];
$entity_type = $field_instance['entity_type'];
return array(
'field_name' => $field_name,
'langcode' => $langcode,
'delta' => $delta,
'entity_type' => $entity_type,
);
}