Pour obtenir le sélecteur de date sur le nouveau formulaire d'inscription, je devais include javascripts
dans le modèle indexSuccess de ma forme (ma faute)
que pour la plage de l'année, j'ai modifié le fichier de plug-in pour inclure paramètre supplémentaire
class sfWidgetFormDateJQueryUI extends sfWidgetForm
{
protected function configure($options = array(), $attributes = array())
{
if(sfContext::hasInstance())
$this->addOption('culture', sfContext::getInstance()->getUser()->getCulture());
else
$this->addOption('culture', "en");
$this->addOption('change_month', false);
$this->addOption('change_year', false);
$this->addOption('number_of_months', 1);
$this->addOption('show_button_panel', false);
$this->addOption('theme', '/sfJQueryUIPlugin/css/ui-lightness/jquery-ui.css');
$this->addOption('year_range', '-30:+0');
parent::configure($options, $attributes);
}
public function render($name, $value = null, $attributes = array(), $errors = array())
{
$attributes = $this->getAttributes();
$input = new sfWidgetFormInput(array(), $attributes);
$html = $input->render($name, $value);
$id = $input->generateId($name);
$culture = $this->getOption('culture');
$cm = $this->getOption("change_month") ? "true" : "false";
$cy = $this->getOption("change_year") ? "true" : "false";
$nom = $this->getOption("number_of_months");
$sbp = $this->getOption("show_button_panel") ? "true" : "false";
$yrs = $this->getOption("year_range");
if ($culture!='en')
{
$html .= <<<EOHTML
<script type="text/javascript">
$(function() {
var params = $.datepicker.regional['$culture'];
params.changeMonth = $cm;
params.changeYear = $cy;
params.numberOfMonths = $nom;
params.showButtonPanel = $sbp;
params.yearRange = "$yrs";
$("#$id").datepicker(params);
});
</script>
EOHTML;
}
else
{
$html .= <<<EOHTML
<script type="text/javascript">
$(function() {
var params = {
changeMonth : $cm,
changeYear : $cy,
numberOfMonths : $nom,
showButtonPanel : $sbp,
yearRange : "$yrs"
};
$("#$id").datepicker(params);
});
</script>
EOHTML;
}
return $html;
}
public function getStylesheets()
{...
}
public function getJavaScripts()
{...
}
}
et la configuration du widget comme:
$this->widgetSchema['date_of_birth']= new sfWidgetFormDateJQueryUI(array("change_month" => true, "change_year" => true, "theme" => "smoothness/jquery-ui-1.8.custom.css", "year_range" => "-30:+0"));
Je l'ai déjà consigné la demande de fonctionnalité et le bug. Je veux juste savoir si quelqu'un d'autre est confronté à ce problème? et a trouvé une solution de rechange? – Prasad