You are here

function wf_crm_get_defaults in Webform CiviCRM Integration 7.4

Same name and namespace in other branches
  1. 7.5 includes/contact_component.inc \wf_crm_get_defaults()

Returns a default value for a component.

Parameters

object $node:

Return value

array

1 call to wf_crm_get_defaults()
_webform_render_civicrm_contact in includes/contact_component.inc
Implements _webform_render_component().

File

includes/contact_component.inc, line 1201

Code

function wf_crm_get_defaults($node) {
  $defaults = array();
  foreach ($node->webform['components'] as $comp) {
    if (!empty($comp['value'])) {
      $key = str_replace('_', '-', $comp['form_key']);
      $defaults[$key] = $comp['type'] == 'date' ? date('Y-m-d', strtotime($comp['value'])) : $comp['value'];
    }
  }
  return $defaults;
}