sfWidgetFormInputNumber.class.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /*
  3. * Inspired by sfWidgetFormInput.class.php
  4. */
  5. /**
  6. * sfWidgetFormInput represents an HTML input number tag.
  7. *
  8. * @package symfony
  9. * @subpackage widget
  10. * @author Simon WIRTH
  11. */
  12. class sfWidgetFormInputNumber extends sfWidgetForm
  13. {
  14. /**
  15. * Constructor.
  16. *
  17. * Available options:
  18. *
  19. * * type: The widget type (text by default)
  20. *
  21. * @param array $options An array of options
  22. * @param array $attributes An array of default HTML attributes
  23. *
  24. * @see sfWidgetForm
  25. */
  26. protected function configure($options = array(), $attributes = array())
  27. {
  28. $this->addOption('type', 'number');
  29. $this->setOption('is_hidden', false);
  30. }
  31. /**
  32. * @param string $name The element name
  33. * @param string $value The value displayed in this widget
  34. * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
  35. * @param array $errors An array of errors for the field
  36. *
  37. * @return string An HTML tag string
  38. *
  39. * @see sfWidgetForm
  40. */
  41. public function render($name, $value = null, $attributes = array(), $errors = array())
  42. {
  43. return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
  44. }
  45. }