CakePHP - saving dates in your model
Learning continues! Today I learned about Controller::cleanUpFields().
If you’ve used CakePHP’s scaffolding and are ready to create your own views you might run into a problem saving dates into your database.
Here’s the scenario:
You have a table with a datetime field in it. In your view you have a form that saves a date and the date field is create with the HTMLHelper:
$html->dateTimeOptionTag();
In your controller you have a simple Model::save() call to save your new record but low and behold your date is set to NULL.
Apparently CakePHP does not do a great job of automatically taking the selections that are created by dateTimeOptionTag() and converting them into a datetime string for the database.
Instead, before you call Model::save() you need to call Controller::cleanUpFields(); it will do some magic and give you a date string that the database likes.
Importing multiple pdf pages and documents into PDFlib - Part 2
This is a followup to my first post about importing multiple pages into PDFlib .
I have created a class that will allow you to import multi page PDF’s as well as importing multiple PDF documents into one generated PDF. It will also fill all of your PDFlib text blocks with the data you provide:
Please post any questions or comments about it.
Here’s the class on pastie: http://pastie.caboo.se/14052
Here’s the code:
# — HERE’S HOW TO USE THIS CLASS
# Created by Nate Constant, http://shabadeehoob.com . Please contact me if you need help using it
=begin
1. open your PDF doc in Acrobat Standard (or Pro).
2. using the PDFlib block tool draw your text blocks in your pdf where you want them
a. if you are drawing blocks for checkboxes make sure to set the font to “ZapfDingbats” —IMPORTANT: dont use “Zapf Dingbats” <- see the space in there?
b. if you are drawing blocks that are supposed to circle something (i.e. “circle your answer”) make sure to set the font size to something large to make the circle
3. use the “Save As” to save your pdf into the directory you want (probably the directory in your rails app because you can access it via #{RAILS_ROOT})
4. in this class go to the “fill_app” method and set your “searchpath”. this is the path for your pdf doc in your rails app
5. point your browser to the generate_pdf action and let er rip!
=end
end
Update: Tony Buser has modified this code by making it into a hash object. View it here
Quick Link - Every CSS based layout you could want
I stumbled across this article that has about every CSS-based design layout you could possibly want and I thought I would share:
http://blog.html.it/layoutgala/It has over 40 CSS-based layouts with code examples.
Recently
- 08.24 Setting up flash messages in Zend Framework
- 09.08 CakePHP default dateTime()
- 03.24 Extending CakePHP’s beforeFilter()
- 03.17 Rails-like Flash messages in CakePHP
- 03.08 CakePHP thumbnails with phpThumb
- 02.15 CakePHP model validation
- 02.10 CakePHP - saving dates in your model
- 09.19 Importing multiple pdf pages and documents into PDFlib - Part 2
- 09.18 Quick Link - Every CSS based layout you could want
- 09.04 Mongrel pid error fixed