I’m talking about this plugin: http://www.symfony-project.org/plugins/sfFormExtraPlugin
For some reason, getting the plugin to work took a lot of Googling and some trial and error.
So here is how I got it working. Hopefully I did this in the ‘correct’ way…
cd plugins wget "http://plugins.symfony-project.org/get/sfFormExtraPlugin/sfFormExtraPlugin-1.1.3.tgz" tar zxvf sfFormExtraPlugin-1.1.3.tgz mv sfFormExtraPlugin-1.1.3 sfFormExtraPlugin cd .. ./symfony plugin:publish-assets cd web/js wget "http://code.jquery.com/jquery-1.4.3.min.js" wget "http://jqueryui.com/download/jquery-ui-1.8.5.custom.zip" mkdir jquery-ui cd jquery-ui unzip ../jquery-ui-1.8.5.custom.zip mv jquery-ui/css/smoothness ../css
Edit config/ProjectConfiguration.class.php to add sfFormExtraPlugin as an enabled plugin:
class ProjectConfiguration extends sfProjectConfiguration { public function setup() { $this->enablePlugins(array('sfDoctrinePlugin', 'sfFormExtraPlugin')); } }
Edit apps/<app_name>/config/view.yml to include the JS and CSS:
stylesheets: [main.css, smoothness/jquery-ui-1.8.5.custom.css] javascripts: [jquery-1.4.3.min.js, jquery-ui/js/jquery-ui-1.8.5.custom.min.js]
Edit lib/form/doctrine/<your_module_name>Form.class.php to make use of the widgets you want. I’m interested in sfWidgetFormJQueryDate:
public function configure() { $this->widgetSchema['created_at'] = new sfWidgetFormJQueryDate(array( 'image' => '/images/silk_icons/calendar.png', 'config' => '{}', )); $this->widgetSchema['updated_at'] = new sfWidgetFormJQueryDate(array( 'image' => '/images/silk_icons/calendar.png', 'config' => '{}', )); }
I have used the calendar.png icon from the famfamfam silk icon set. You can get the set here: http://www.famfamfam.com/lab/icons/silk/
I’ve used the date picker widget for filling in the created_at and updated_at fields. You can replace these values with the fields you need to manipulate in a user friendly way.
[Edit 17/10/2010:]
I’m not going mad, there is an issue with the ‘magic’ fields created_at and updated_at in that they have to be unset to become magic.
Found help here: http://levelx.me/technology/programming/symfony-1-4-doctrine-timestampable-behaviour/
Though the unset lines are better off being added just once to /lib/form/doctrine/BaseFormDoctrine.class.php, rather than each xxxForm.class.php file.
bonjour,merci pour ce tuto,mais vu que je suis débutant,j’ai tout fait mais comment je peux tester l’aperçu,quelle url faut taper sur le navigateur pour que je vérifie l’affichage du calendrier.
NB:c’est un nouveau projet vide,juste j’ai volu tester ce plugin
Merci de m’aider svp 🙂
— Edit by Iain —
Google translate says:
hello, thank you for this tutorial, but since I’m a beginner, I did everything but how can I test the preview, what url should tap the browser so I checked the calendar view.
NB: this is a new empty project, I just tested this plugin volumes
Thank you help me please:)
Hi !
Even after following all these steps it’s still possible that date pickers won’t work. In my case the following message is displayed :-/
Fatal error: Class ‘sfWidgetFormJqueryDate’ not found in /path/to/project/lib/form/doctrine/TestForm.class.php on line 17
I think this problem is related to the fact that there’s no reference to plugin files in plugins/.filemap . I managed to get this working by adding the following statement at the beginning of form class php file.
require dirname(__FILE__).’/../../../plugins/sfFormExtraPlugin/lib/widget/sfWidgetFormJQueryDate.class.php’;
Nonetheless I’d really appreciate if someone can mention how to avoid inserting this line. For further details, the whole process I followed is very similar to this and is explained in this article (Spanish).
http://simelo-es.blogspot.com/2011/11/insertando-calendarios-de-jquery-con.html
English translation coming soon, but in the mean time please try Google Translate gadget in top-left corner. Thanks in advance !