sfWidgetFormInput.class.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * sfWidgetFormInput represents an HTML input tag.
  11. *
  12. * @package symfony
  13. * @subpackage widget
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfWidgetFormInput.class.php 9046 2008-05-19 08:13:51Z FabianLange $
  16. */
  17. class sfWidgetFormInput extends sfWidgetForm
  18. {
  19. /**
  20. * Constructor.
  21. *
  22. * Available options:
  23. *
  24. * * type: The widget type (text by default)
  25. *
  26. * @param array $options An array of options
  27. * @param array $attributes An array of default HTML attributes
  28. *
  29. * @see sfWidgetForm
  30. */
  31. protected function configure($options = array(), $attributes = array())
  32. {
  33. $this->addOption('type', 'text');
  34. $this->setOption('is_hidden', false);
  35. }
  36. /**
  37. * @param string $name The element name
  38. * @param string $value The value displayed in this widget
  39. * @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
  40. * @param array $errors An array of errors for the field
  41. *
  42. * @return string An HTML tag string
  43. *
  44. * @see sfWidgetForm
  45. */
  46. public function render($name, $value = null, $attributes = array(), $errors = array())
  47. {
  48. return $this->renderTag('input', array_merge(array('type' => $this->getOption('type'), 'name' => $name, 'value' => $value), $attributes));
  49. }
  50. }