MultipleRequired.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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. *
  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. *
  26. * @return bool true if value is not empty
  27. */
  28. public function validate($value, $options = null)
  29. {
  30. if (is_array($value)) {
  31. $value = implode(null, $value);
  32. }
  33. if ((string) $value == '') {
  34. return false;
  35. }
  36. return true;
  37. }
  38. // end func validate
  39. public function getValidationScript($options = null)
  40. {
  41. return ['', "{jsVar} == ''"];
  42. }
  43. }