MultipleRequired.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /* vim: set expandtab tabstop=4 shiftwidth=4: */
  3. // +----------------------------------------------------------------------+
  4. // | PHP version 4.0 |
  5. // +----------------------------------------------------------------------+
  6. // | Copyright (c) 1997-2003 The PHP Group |
  7. // +----------------------------------------------------------------------+
  8. // | Copy of the existing rule "required" to check if at least one element|
  9. // | has been filled. Then $value can be an array |
  10. // +----------------------------------------------------------------------+
  11. // | Authors: Eric Marguin <e.marguin@elixir-interactive.com> |
  12. // +----------------------------------------------------------------------+
  13. /**
  14. * Required elements validation
  15. * @version 1.0
  16. */
  17. class HTML_QuickForm_Rule_MultipleRequired extends HTML_QuickForm_Rule
  18. {
  19. /**
  20. * Checks if all the elements are empty
  21. *
  22. * @param string $value Value to check (can be an array)
  23. * @param mixed $options Not used yet
  24. * @access public
  25. * @return boolean true if value is not empty
  26. */
  27. function validate($value, $options = null)
  28. {
  29. if (is_array($value))
  30. {
  31. $value = implode(null, $value);
  32. }
  33. if ((string) $value == '') {
  34. return false;
  35. }
  36. return true;
  37. } // end func validate
  38. function getValidationScript($options = null)
  39. {
  40. return array('', "{jsVar} == ''");
  41. } // end func getValidationScript
  42. } // end class HTML_QuickForm_Rule_MultipleRequired