You are here

function _webform_render_mobile_number in Mobile Number 7

Webform mobile number widget.

File

components/mobile_number.inc, line 42
Mobile_number.inc.

Code

function _webform_render_mobile_number($component, $value = NULL, $filter = TRUE) {
  $node = isset($component['nid']) ? node_load($component['nid']) : NULL;
  $settings = $component['extra'];
  $title_display_map = array(
    'before' => 'before',
    'inline' => 'after',
    'none' => 'invisible',
  );
  $element = array(
    '#title' => $component['name'],
    '#title_display' => $title_display_map[$settings['title_display']],
    '#required' => $component['required'],
    '#weight' => $component['weight'],
    '#type' => 'mobile_number',
    '#description' => $settings['description'],
    '#default_value' => $value ? $value : array(),
    '#mobile_number' => array(
      'allowed_countries' => $settings['countries'],
      'verify' => mobile_number_sms_sending_is_enabled() ? $settings['verify'] : MOBILE_NUMBER_VERIFY_NONE,
      'message' => $settings['message'],
      'token_data' => !empty($node) ? array(
        'node' => $node,
      ) : array(),
      'placeholder' => !empty($settings['placeholder']) ? $settings['placeholder'] : '',
    ),
  );
  $element['#default_value'] += array(
    'country' => $settings['default_country'],
  );
  return $element;
}