function mobile_number_field_widget_settings_form in Mobile Number 7
Implements hook_field_widget_settings_form().
1 call to mobile_number_field_widget_settings_form()
- _webform_edit_mobile_number in components/
mobile_number.inc - Webform mobile number settings form.
File
- ./
mobile_number.module, line 388 - mobile_number.module
Code
function mobile_number_field_widget_settings_form($field, $instance) {
$settings = $instance['widget']['settings'];
$verification_enabled = $field['type'] == 'mobile_number';
$form = array();
$form['default_country'] = array(
'#type' => 'select',
'#title' => t('Default Country'),
'#options' => MobileNumber::getCountryOptions(array(), TRUE),
'#default_value' => !empty($settings['default_country']) ? $settings['default_country'] : 'US',
'#description' => t('Default country for mobile number input.'),
'#required' => TRUE,
'#element_validate' => array(
'mobile_number_field_widget_settings_validate',
),
);
$form['countries'] = array(
'#type' => 'select',
'#title' => t('Allowed Countries'),
'#options' => MobileNumber::getCountryOptions(array(), TRUE),
'#default_value' => !empty($settings['countries']) ? $settings['countries'] : NULL,
'#description' => t('Allowed counties for the mobile number. If none selected, then all are allowed.'),
'#multiple' => TRUE,
'#attached' => array(
'css' => array(
drupal_get_path('module', 'mobile_number') . '/css/mobile-number-form-element.css',
),
),
);
$form['placeholder'] = array(
'#type' => 'textfield',
'#title' => t('Number Placeholder'),
'#default_value' => isset($settings['placeholder']) ? $settings['placeholder'] : 'Phone number',
'#description' => t('Number field placeholder.'),
'#required' => FALSE,
);
if ($verification_enabled) {
$form['verify'] = array(
'#type' => 'radios',
'#title' => t('Verification'),
'#options' => array(
MOBILE_NUMBER_VERIFY_NONE => t('None'),
MOBILE_NUMBER_VERIFY_OPTIONAL => t('Optional'),
MOBILE_NUMBER_VERIFY_REQUIRED => t('Required'),
),
'#default_value' => !empty($settings['verify']) ? $settings['verify'] : MOBILE_NUMBER_VERIFY_NONE,
'#description' => t('Verification requirement. Will send sms to mobile number when user requests to verify the number as their own. Requires <a href="https://www.drupal.org/project/smsframework" target="_blank">SMS Framework</a> or any other sms sending module that integrates with with the Mobile Number module.'),
'#required' => TRUE,
'#disabled' => !mobile_number_sms_sending_is_enabled(),
);
$form['message'] = array(
'#type' => 'textarea',
'#title' => t('Verification Message'),
'#default_value' => isset($settings['message']) ? $settings['message'] : MOBILE_NUMBER_DEFAULT_SMS_MESSAGE,
'#description' => t('The SMS message to send during verification. Replacement parameters are available for verification code (!code) and site name (!site_name). Additionally, tokens are available if the token module is enabled, but be aware that entity values will not be available on entity creation forms as the entity was not created yet.'),
'#required' => TRUE,
'#disabled' => !mobile_number_sms_sending_is_enabled(),
);
if (module_exists('token')) {
$form['message']['#element_validate'] = array(
'token_element_validate',
);
$form['message']['#token_types'] = array(
$instance['entity_type'],
);
$form['message_token_tree']['token_tree'] = array(
'#theme' => 'token_tree',
'#token_types' => array(
$instance['entity_type'],
),
'#dialog' => TRUE,
);
}
}
return $form;
}