Rich Date Input Widget for Symfony 1.1 Forms
I noticed that for some reason the 1.1 forms do not allow for the rich date input that many people like to use, so I just created a new widget that allows for rich date input. See below for the widget’s code. It uses the input_date_tag widget in the ‘Form’ helper.
/**
* myWidgetFormRichDate is a rich date widget for 1.1+ forms
*
* @author Matt Daum matt [at] setfive.com
*/
class myWidgetFormRichDate extends sfWidgetFormDate
{
/**
* @param array $options An array of options
* @param array $attributes An array of default HTML attributes
*
* @see sfWidgetForm
*/
protected function configure($options = array(), $attributes = array())
{
parent::configure($options, $attributes);
}
/**
* @param string $name The element name
* @param string $value The value displayed in this widget
* @param array $attributes An array of HTML attributes to be merged with the default HTML attributes
* @param array $errors An array of errors for the field
*
* @return string An HTML tag string
*
* @see sfWidgetForm
*/
public function render($name, $value = null, $attributes = array(), $errors = array())
{
//Get the date input function from Form helper
use_helper(’Form’);
//Make the widget rich
$attributes['rich']=true;
return input_date_tag($name,$value, $attributes);
}
}

Thank you !
Awesome. I’ve also been looking for this.
Thanks a lot!
thanks a lot!
Thanks, this was helpful.
For anyone copy and pasting this widget code. The line
use_helper(’Form’);
has funky single quotes (’) that need to be changed to straight quotes (’).
[...] order to set the value of rich = true in the input_date_tag method, we need to create a custom rich date widget. I simply followed setfive’s [...]
I am to new symfony and using input_date_tag() in my files results in an error.
How would I get this working in symfony 1.2.0?
vfclists- in Symfony 1.2 you don’t need the above widget. Instead you can just use the sfFormExtraPlugin to get the rich date widget. http://www.symfony-project.org/plugins/sfFormExtraPlugin is the link to the plugin, I suggest you use it rather than the above widget.
I am to new symfony and using input_date_tag() in my files results in an error.
How would I get this working in symfony 1.2.0?
Are there any libraries, helpers and plugins I need to add to the forms code?