webform_phone.module 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /**
  3. * @file
  4. * Information about phone fields for webform module
  5. */
  6. /**
  7. * Implements hook_webform_component_info().
  8. */
  9. function webform_phone_webform_component_info() {
  10. $components = array();
  11. $components['phone'] = array(
  12. 'label' => t('Phone Number'),
  13. 'description' => t('Phone Number field.'),
  14. 'features' => array(
  15. // Add content to CSV downloads. Defaults to TRUE.
  16. 'csv' => TRUE,
  17. // Show this component in e-mailed submissions. Defaults to TRUE.
  18. 'email' => TRUE,
  19. // Allow this component to be used as an e-mail FROM or TO address.
  20. // Defaults to FALSE.
  21. 'email_address' => FALSE,
  22. // Allow this component to be used as an e-mail SUBJECT or FROM name.
  23. // Defaults to FALSE.
  24. 'email_name' => FALSE,
  25. // This component may be toggled as required or not. Defaults to TRUE.
  26. 'required' => TRUE,
  27. // This component has a title that can be toggled as displayed or not.
  28. 'title_display' => TRUE,
  29. // This component has a title that can be displayed inline.
  30. 'title_inline' => TRUE,
  31. // If this component can be used as a conditional SOURCE. All components
  32. // may always be displayed conditionally, regardless of this setting.
  33. // Defaults to TRUE.
  34. 'conditional' => TRUE,
  35. // If this component allows other components to be grouped within it
  36. // (like a fieldset or tabs). Defaults to FALSE.
  37. 'group' => FALSE,
  38. // If this component can be used for SPAM analysis, usually with Mollom.
  39. 'spam_analysis' => FALSE,
  40. // If this component saves a file that can be used as an e-mail
  41. // attachment. Defaults to FALSE.
  42. 'attachment' => FALSE,
  43. ),
  44. 'file' => 'webform_phone.components.inc',
  45. );
  46. return $components;
  47. }
  48. /**
  49. * Implements hook_webform_validator_alter().
  50. */
  51. function webform_phone_webform_validator_alter(&$validators) {
  52. $validators['unique']['component_types'][] = 'phone';
  53. // webform_validaton combined 'oneoftwo' and 'oneofseveral' into 'someofseveral' as of 7.x-1.5
  54. if ( array_key_exists('oneoftwo', $validators) ) {
  55. $validators['oneoftwo']['component_types'][] = 'phone';
  56. }
  57. if ( array_key_exists('oneofseveral', $validators) ) {
  58. $validators['oneofseveral']['component_types'][] = 'phone';
  59. }
  60. if ( array_key_exists('someofseveral', $validators) ) {
  61. $validators['someofseveral']['component_types'][] = 'phone';
  62. }
  63. }