function _formdefaults_get_field in Form Defaults 7
Same name and namespace in other branches
- 8 formdefaults.module \_formdefaults_get_field()
- 5.3 formdefaults.module \_formdefaults_get_field()
- 5 formdefaults.module \_formdefaults_get_field()
- 5.2 formdefaults.module \_formdefaults_get_field()
- 6.2 formdefaults.module \_formdefaults_get_field()
- 6 formdefaults.module \_formdefaults_get_field()
Recursively iterate through the form array to save titles and descirptions. The the resulting title/description array is intentionally flattened to make indexing easier during the "replacement" portion of the code. Also tack on the [edit] link.
Parameters
$formid the formid of the form we're altering:
$fieldname the fieldname of the last form field we found.:
$fieldvalue The array of field values that we found last.:
$fieldarray We store the array of titles and desciptions in this array for storing later.:
1 call to _formdefaults_get_field()
- formdefaults_form_alter in ./
formdefaults.module - implements hook_form_alter
File
- ./
formdefaults.module, line 157
Code
function _formdefaults_get_field($formid, $fieldname, &$fieldvalue, &$fieldarray) {
if (is_array($fieldvalue) && !(strpos($fieldname, '#') === 0)) {
// Determine return location for links.
$query = array();
$query['destination'] = $_GET['q'];
if (is_array($query)) {
$query = drupal_http_build_query($query);
$options['query'] = $query;
}
$options = array();
$type = @$fieldvalue['#type'];
$fieldarray[$fieldname]['type'] = $type;
// Skip submit and hidden fields cause they're too dangerous to alter.
if ($type != 'submit' && $type != 'hidden') {
if (array_key_exists('#weight', $fieldvalue)) {
$fieldarray[$fieldname]['weight'] = $fieldvalue['#weight'];
}
else {
$fieldarray[$fieldname]['weight'] = 'unset';
}
if ($type == 'markup') {
$fieldarray[$fieldname]['value'] = @$fieldvalue['#markup'];
$fieldvalue['#markup'] = l('[' . t('edit markup') . ']', 'formdefaults/' . $formid . '/' . $fieldname, $options) . ' ' . @$fieldvalue['#markup'];
}
else {
$fieldarray[$fieldname]['title'] = @$fieldvalue['#title'];
$fieldarray[$fieldname]['description'] = @$fieldvalue['#description'];
$fieldvalue['#description'] = l('[' . t('edit @type', array(
'@type' => @$fieldvalue['#type'],
)) . ']', 'formdefaults/' . $formid . '/' . $fieldname, $options) . ' ' . @$fieldvalue['#description'];
}
}
foreach ($fieldvalue as $key => $value) {
if (!(strpos($key, '#') === 0)) {
_formdefaults_get_field($formid, $key, $fieldvalue[$key], $fieldarray);
}
}
}
}