Element.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /**
  3. *
  4. * PHP Pro Bid $Id$ 3sSTOjxP87cZKBtQeSSxZyj51wCJf3IH7ncypRzht28=
  5. *
  6. * @link http://www.phpprobid.com
  7. * @copyright Copyright (c) 2014 Online Ventures Software LTD & CodeCube SRL
  8. * @license http://www.phpprobid.com/license Commercial License
  9. *
  10. * @version 7.0
  11. */
  12. /**
  13. * base form element class
  14. *
  15. */
  16. namespace Ppb\Form;
  17. use Cube\Form\Element as ElementBase;
  18. class Element extends ElementBase
  19. {
  20. /**
  21. *
  22. * method to create a new form element
  23. *
  24. * @param string $element the element type
  25. * @param string $name the name of the element
  26. * @return \Cube\Form\Element returns a form element object
  27. */
  28. protected function _createElement($element, $name)
  29. {
  30. $elementClass = '\\Cube\\Form\\Element\\' . ucfirst($element);
  31. if (class_exists($element)) {
  32. return new $element($name);
  33. }
  34. else if (class_exists($elementClass)) {
  35. return new $elementClass($name);
  36. }
  37. else {
  38. return new Element($element, $name);
  39. }
  40. }
  41. }