MultipleRequired.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. require_once('HTML/QuickForm/Rule.php');
  14. /**
  15. * Required elements validation
  16. * @version 1.0
  17. */
  18. class HTML_QuickForm_Rule_MultipleRequired extends HTML_QuickForm_Rule
  19. {
  20. /**
  21. * Checks if all the elements are empty
  22. *
  23. * @param string $value Value to check (can be an array)
  24. * @param mixed $options Not used yet
  25. * @access public
  26. * @return boolean true if value is not empty
  27. */
  28. function validate($value, $options = null)
  29. {
  30. if(is_array($value))
  31. {
  32. $value = implode(null,$value);
  33. }
  34. if ((string)$value == '') {
  35. return false;
  36. }
  37. return true;
  38. } // end func validate
  39. function getValidationScript($options = null)
  40. {
  41. return array('', "{jsVar} == ''");
  42. } // end func getValidationScript
  43. } // end class HTML_QuickForm_Rule_MultipleRequired
  44. ?>