I have the statement
$this->setWidget('one_date', new sfWidgetFormDate(array('format' => '%year% %month%' )));
one_date
in MySQL is a timestamp. This shows me the selected list with year and selected list with month. How can i change this for input text for month and input text for year? If I try changing with: sfWidgetFormInputText
then I have an error:
sfWidgetF开发者_如何学GoormInputText does not support the following options: 'format', 'years'.
You would need two separate text fields that you combine after submission to create your one_date.
Doing it this way could make validation tricky.
$this->setWidgets(array(
'month' => new sfWidgetFormInputText(),
'year' => new sfWidgetFormInputText()
));
$this->setValidators(array(
'month' => new sfValidatorInteger(),
'year' => new sfValidatorInteger()
));
if ($this->form->isValid()) {
$one_date = $this->form->getValue('month') . $this->form->getValue('year');
}
精彩评论