Bonjour, j'ai un champ de date sfWidgetFormJQueryDate inclu dans sfFormExtraPlugin. Mais comme son ancêtre sfWidgetFormDateTime, la plage des années par défaut est très limitée. Pourriez vous me donner une idée de comment l'étendre ? merci.
Version imprimable
Bonjour, j'ai un champ de date sfWidgetFormJQueryDate inclu dans sfFormExtraPlugin. Mais comme son ancêtre sfWidgetFormDateTime, la plage des années par défaut est très limitée. Pourriez vous me donner une idée de comment l'étendre ? merci.
La doc de l'objet sfWidgetFormDate dit :
Tu dois y trouver ta réponse...Citation:
/**
* Configures the current widget.
*
* Available options:
*
* * format: The date format string (%month%/%day%/%year% by default)
* * years: An array of years for the year select tag (optional)
* Be careful that the keys must be the years, and the values what will be displayed to the user
* * months: An array of months for the month select tag (optional)
* * days: An array of days for the day select tag (optional)
* * can_be_empty: Whether the widget accept an empty value (true by default)
* * empty_values: An array of values to use for the empty value (empty string for year, month, and day by default)
*
* @param array $options An array of options
* @param array $attributes An array of default HTML attributes
*
* @see sfWidgetForm
*/
J'ai fais ceci
et ça a réponduCode:'datenaissance' => new sfWidgetFormJQueryDate(array('years' => array('1940', '2000')), array('image'=>'/images/calendar.png', 'culture'=>'fr')),
J'ai remarqué que l'API ne comporte d'informations spécifiques pour sfWidgetFormJQueryDate. Toutefois, l'erreur est la même pour sfWidgetFormDateTime.Code:sfWidgetFormJQueryDate does not support the following options: 'years'.
En passant, bravo pour tes nouveaux gallons:ccool:
Arg, je n'ai pas vu que c'était pour un sfWidgetFormJQueryDate. C'est un brin plus compliqué.
En effet, le sfWidgetFormJQueryDate embarque en fait deux plugins différents : un sfWidgetFormDate pour les champs dates et un plugin jQuery.Calendar pour la partie affichage. Les deux sont à configurer séparément.
La doc dit :
Tu peux donc voir que tu peux lui joindre un objet sfWidgetFormDate dans l'argument date_widget. Widget que tu auras configuré au préalable. Ceci devrait permettre de résoudre la liste des dates dans les listes déroulantes.Citation:
/**
* Configures the current widget.
*
* Available options:
*
* * image: The image path to represent the widget (false by default)
* * config: A JavaScript array that configures the JQuery date widget
* * culture: The user culture
* * date_widget: The date widget instance to use as a "base" class
*
* @param array $options An array of options
* @param array $attributes An array of default HTML attributes
*
* @see sfWidgetForm
*/