[fw-general] Re: generic way of processing forms and modifying underlying database table accordingly
BillKarwin wrote: In general, you can do this only if your form and your database table are trivial. For example, no multi-value form fields, no multi-value data elements, and form fields have a one-to-one mapping to database columns with the same data types and same names, etc. This is almost never true, unless you're only developing a demo. Form processing is complex because information is complex. There is no form processing that is as simple as you describe, while also supporting the range of options that developers need. Regards, Bill Karwin In a very simple form, this is how it could work: You distinguish three modes: add, edit, delete. This is always indicated, for example, by a parameter 'mode'. You give the fields in your form the same name as the columns in your database. You link this form to a db-table object. When you process the form, you first validate it (like you normally would) and when no errors have been found you poopulate the object of your db-table class with the values of the form (which is easy, because the names are the same) and save it. That still leaves some issues to deal with: - the (automatically) generated primary keys - multivalue form fields - forms that have multiple underlying tables The first is relative easy to tackle as well. Like the 'modes' field, you also determine which field will always contain the value of the primary key. If you have multiple db columns, you create this form-field as an array. Your db-table class should be (made) aware of these primary key columns and that's how you can populate them or extract them when necessary. Multivalue formfields: simply link them to other db-table objects and give them a special treatment. They would be ignored at first, since the 'main' table doesn't contain this column, so no problem there. Then it's just a matter of updating the underlying table in such a way that for the primary key of the 'main' form, only the posted values are linked. And i think the last one should be doable too. I was thinking this could probably be solved using subforms. That way you can isolate the values, map them to other db-table objects and process them in a similar way. I think this deals already with a lot of possible issues. What other 'big' issues do you see for this not be interesting to consider pursuing? Simon Walter-2 wrote: The only oddball is the id which would be automatically generated by the db. I think that one is relatively easy to solve (see above) Perhaps what would be useful is for Zend_Tool to output skeleton code for a form using a db table to determine what fields are needed, etc. It would be a nice starting point, from which you could modify to suit your requirements. Of course there are bigger issues and features to work on. Though, in the future, that would be nice to have. I don't agree. The main reason i'm using a framework is because it offers a generic solution to problems i'm faced with every day when i write code. Instead of writing lots of code over and over again, the framework provides a way to configure a few things so i can do the same thing with only a few lines of code. That saves me a huge amount of time and makes the code much more easy to maintain. That it also contains stand alone modules is a nice bonus but these should never be the main priority in my opinion. And this is exactly such a thing that could save so much time for so many people: i'm almost sure that every user of the zend framework is at one point or another writing and duplicating lots of code to process their forms, so this should be at the top of the list -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/generic-way-of-processing-forms-and-modifying-underlying-database-table-accordingly-tp3244032p3334854.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Re: Crappy Thumbnails from generated pdf
On 03/03/2011 12:24 AM, Stefan Riffert wrote: Hello HTH, Unfortunately scribus only supports svg, eps and pdf. I had some mails with the developers of scribus. The option to invoke scibus in the commandline is planned. But no one knows when... I also asked if there is any option to convert the src files to FO or something like this. Nothing. Using svg might be a solution. The problem is, that my time is short and I never worked with svg like this. Do you know some libraries that provide functionality to add text and images to svg files? Or where to start reading? It doesn't seem like an easy task to accomplish with limited time. SVG is an XML format. So basically a decent XML parser would serve the purpose. However, there are lots of CLI SVG tool kits that will probably save you much time. See: http://www.w3.org/Graphics/SVG/ http://www.w3.org/Graphics/SVG/WG/wiki/Implementations Years ago that page had many more implementations. I assume Batik is the best, so they dropped the rest. SVG is very scripting friendly. I'm not 100% sure what you are trying to do, but I had a look at the Scribus PDF form support. I guess you want to insert the user's values into the form and generate the PDF. So, if you have the Scribus document exported as an SVG file, you'd navigate the DOM to find the element you want to add the text to. You may need to use place holder text in the SVG file and then replace that text rather than insert it. You'll have to ask the SVG gurus about that. I think it's probably the cleanest and most maintainable way to achieve your goal. Props for using FOSS. d HTH
Re: [fw-general] Zend Framework 1.11.4 Released
I'm using it now. I noticed Zend_Tool generates working tests. I was pleasantly surprised! It probably was from an older release and I just noticed now...
[fw-general] Re: Crappy Thumbnails from generated pdf
Hey, that sounds like an approach to follow. I'll see. Thanks a lot for your information. Regards student Am 04.03.2011 12:05, schrieb Simon Walter [via Zend Framework Community]: On 03/03/2011 12:24 AM, Stefan Riffert wrote: Hello HTH, Unfortunately scribus only supports svg, eps and pdf. I had some mails with the developers of scribus. The option to invoke scibus in the commandline is planned. But no one knows when... I also asked if there is any option to convert the src files to FO or something like this. Nothing. Using svg might be a solution. The problem is, that my time is short and I never worked with svg like this. Do you know some libraries that provide functionality to add text and images to svg files? Or where to start reading? It doesn't seem like an easy task to accomplish with limited time. SVG is an XML format. So basically a decent XML parser would serve the purpose. However, there are lots of CLI SVG tool kits that will probably save you much time. See: http://www.w3.org/Graphics/SVG/ http://www.w3.org/Graphics/SVG/WG/wiki/Implementations Years ago that page had many more implementations. I assume Batik is the best, so they dropped the rest. SVG is very scripting friendly. I'm not 100% sure what you are trying to do, but I had a look at the Scribus PDF form support. I guess you want to insert the user's values into the form and generate the PDF. So, if you have the Scribus document exported as an SVG file, you'd navigate the DOM to find the element you want to add the text to. You may need to use place holder text in the SVG file and then replace that text rather than insert it. You'll have to ask the SVG gurus about that. I think it's probably the cleanest and most maintainable way to achieve your goal. Props for using FOSS. d HTH If you reply to this email, your message will be added to the discussion below: http://zend-framework-community.634137.n4.nabble.com/Crappy-Thumbnails-from-generated-pdf-tp3329564p3335053.html To unsubscribe from Crappy Thumbnails from generated pdf, click here http://zend-framework-community.634137.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_codenode=3329564code=cmlmZmVydEBsYS13ZWxsLmRlfDMzMjk1NjR8LTIwNjU4MjgwNjE=. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Crappy-Thumbnails-from-generated-pdf-tp3329564p3335144.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Re: adding a REST route chained with another route
Le 02/03/11 21:39, nebiros a écrit : Hey, I was reading a devzone post: http://devzone.zend.com/article/12381 and somebody post a comment about how to prepend something to the default routes, in your case the account, in my case the region, so I wrote this in my application.ini file: resources.router.routes.module.type = Zend_Controller_Router_Route_Module resources.router.routes.region.type = Zend_Controller_Router_Route resources.router.routes.region.route = :region resources.router.routes.region.reqs.region = [a-z]{2} resources.router.routes.region.abstract = 1 resources.router.routes.default.type = Zend_Controller_Router_Route_Chain resources.router.routes.default.chain = region, module So all urls look this way: /:region/:module/:controller/:action Maybe this can help you. -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/adding-a-REST-route-chained-with-another-route-tp3297415p3332254.html Sent from the Zend Framework mailing list archive at Nabble.com. Hi nebiros, Correct me if I am wrong but your configuration file shows how to chain a Zend_Controller_Router_Route to a Zend_Controller_Router_Route_Module. The problem I describe is that the :region variable will be removed from the request if you have two subsequent routes to test and the first one doesn't match. Regards -- Guillaume
Re: [fw-general] Zend Framework 1.11.4 Released
-- Simon Walter si...@gikaku.com wrote (on Friday, 04 March 2011, 08:09 PM +0900): I'm using it now. I noticed Zend_Tool generates working tests. I was pleasantly surprised! It probably was from an older release and I just noticed now... No, that's new with this release, in part due to some issues reported. I forgot to call it out in the release announcement! -- Matthew Weier O'Phinney Project Lead| matt...@zend.com Zend Framework | http://framework.zend.com/ PGP key: http://framework.zend.com/zf-matthew-pgp-key.asc
[fw-general] Newbie : Message: Invalid controller specified
Hi, Im am a newbie in Zend and just enough to understand PHP. I am trying to follow this tutorial : http://akrabat.com/wp-content/uploads/Getting-Started-with-Zend-Framework.pdf which explains things quite clearly . I think I have followed instructions exaqctly. Now I have followed up to creating zf create action add Index zf create action edit Index zf create action delete Index however I am getting this error message. Message: Invalid controller specified (Mangion_RE) Stack trace: #0 C:\mowes_0174\mowes_0174\www\mytest\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard-dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http)) #1 C:\mowes_0174\mowes_0174\www\mytest\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front-dispatch() #2 C:\mowes_0174\mowes_0174\www\mytest\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap-run() #3 C:\mowes_0174\mowes_0174\www\mytest\public\index.php(26): Zend_Application-run() #4 {main} Can anyone help please! -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Newbie-Message-Invalid-controller-specified-tp3334842p3334842.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Re: Zend_Cache cleaning specified tag
Thank you for the answer. How can I clean cache? Regards -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Zend-Cache-cleaning-specified-tag-tp090p3335507.html Sent from the Zend Framework mailing list archive at Nabble.com.
[fw-general] Error on 'non-object'? (Pro PHP book)
Hi. I just recently started learning the Zend Framework and bought an excellent book: pro php by Kevin McArthur. I have been following a lot of the examples there are in the book, but there is one example that doesn't seem to work properly. The error I get is: Fatal error: Call to a member function getActionController() on a non-object in C:\wamp\bin\php\ZendFramework\ZendFramework-1.11.3\library\Zend\Controller\Action\HelperBroker.php on line 299 The error is this line of code: (when I remove it, there is no error :)) $this-getHelper('FlashMessenger')-addMessage($field . ' : '. $message); I hope you can help me out, Nicolai The example is listing 15-16 (if someone has the book): class CustomersController extends Zend_Controller_Action { public function indexAction() { $table = new Customers(); // Må så tage my model Customers (from application/models/Customers.php) $this-view-customers = $table-fetchAll(); } public function redirectasAction() { $this-getHelper('redirector')-goto('index'); } public function redirectAction() { $this-getHelper('FlashMessenger')-addMessage(This was set at the redirector); $this-getHelper('redirector')-goto('show'); } public function showAction() { $this-view-messages = $this-getHelper('FlashMessenger')-getMessages(); } public function addAction() { Zend_Debug::dump($this-getRequest()-getPost()); $request = $this-getRequest(); //Deterine if processing a post request if($request-isPost()) { //Filter tags from the name field $filters = array( 'name' = 'StripTags' ); //Validate name is not less than 1 character and not more than 64 $validation = array( 'name' = array ( array( 'StringLength', 1, 64) ) ); //Initialize Zend_Filter_input passing it the entire getPost() array $zfi = new Zend_Filter_Input($filters, $validation, $request-getPost()); //If the validators passed this will be true if($zfi-isValid()) { //Fetch the data from zfi directly and create an array for Zend_Db $clean = array(); $clean['name'] = $zfi-name; //Create an instance of the customers table and insert the $clean row $customers = new Customers(); $customers-insert($clean); //Redirect to the display page after adding $this-getHelper('redirector')-goto('index'); } else { // The form didn't validate, get the messages from ZFI foreach($zfi-getMessages() as $field=$messages) { //Put each ZFI message into the FlashMessenger so it shows on the form foreach($messages as $message) { $this-getHelper('FlashMessenger')-addMessage($field . ' : '. $message); } } $this-getHelper('redirector')-goto('add'); } } // not a post request, check for flash messages and expose to the view if($this-getHelper('FlashMessenger')-hasMessages()) { $this-view-messages=$this-getHelper('Flashmessenger')-getMessages(); } } } -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Error-on-non-object-Pro-PHP-book-tp3335964p3335964.html Sent from the Zend Framework mailing list archive at Nabble.com.
Re: [fw-general] Error on 'non-object'? (Pro PHP book)
HI Nlissau, Are you able to access any helpers via getHelper or is it only the FlashMessenger that is giving you trouble? I'm also not sure if the getHelper string is case sensitive, but you have a lowercase M in $this-view-messages=$this-getHelper('Flashmessenger')-getMessages(); Which may/may not be causing your issue... Can you paste your call-stack var_dump(debug_backtrace()); The code on line 299 of the helper broker is... if (null === ($actionController = $helper-getActionController())) { Which would seem to imply that $helper is null... which is likely due to the name not being correct. -- Kevin McArthur P.S. Hope you enjoy the book ;) On 11-03-04 01:25 PM, Nlissau wrote: Hi. I just recently started learning the Zend Framework and bought an excellent book: pro php by Kevin McArthur. I have been following a lot of the examples there are in the book, but there is one example that doesn't seem to work properly. The error I get is: Fatal error: Call to a member function getActionController() on a non-object in C:\wamp\bin\php\ZendFramework\ZendFramework-1.11.3\library\Zend\Controller\Action\HelperBroker.php on line 299 The error is this line of code: (when I remove it, there is no error :)) $this-getHelper('FlashMessenger')-addMessage($field . ' : '. $message); I hope you can help me out, Nicolai The example is listing 15-16 (if someone has the book): class CustomersController extends Zend_Controller_Action { public function indexAction() { $table = new Customers(); // Må så tage my model Customers (from application/models/Customers.php) $this-view-customers = $table-fetchAll(); } public function redirectasAction() { $this-getHelper('redirector')-goto('index'); } public function redirectAction() { $this-getHelper('FlashMessenger')-addMessage(This was set at the redirector); $this-getHelper('redirector')-goto('show'); } public function showAction() { $this-view-messages = $this-getHelper('FlashMessenger')-getMessages(); } public function addAction() { Zend_Debug::dump($this-getRequest()-getPost()); $request = $this-getRequest(); //Deterine if processing a post request if($request-isPost()) { //Filter tags from the name field $filters = array( 'name' = 'StripTags' ); //Validate name is not less than 1 character and not more than 64 $validation = array( 'name' = array ( array( 'StringLength', 1, 64) ) ); //Initialize Zend_Filter_input passing it the entire getPost() array $zfi = new Zend_Filter_Input($filters, $validation, $request-getPost()); //If the validators passed this will be true if($zfi-isValid()) { //Fetch the data from zfi directly and create an array for Zend_Db $clean = array(); $clean['name'] = $zfi-name; //Create an instance of the customers table and insert the $clean row $customers = new Customers(); $customers-insert($clean); //Redirect to the display page after adding $this-getHelper('redirector')-goto('index'); } else { // The form didn't validate, get the messages from ZFI foreach($zfi-getMessages() as $field=$messages) { //Put each ZFI message into the FlashMessenger so it shows on the form foreach($messages as $message) { $this-getHelper('FlashMessenger')-addMessage($field . ' : '. $message); } } $this-getHelper('redirector')-goto('add'); } } // not a post request, check for flash messages and expose to the view if($this-getHelper('FlashMessenger')-hasMessages()) { $this-view-messages=$this-getHelper('Flashmessenger')-getMessages(); } } } -- View this message in context: http://zend-framework-community.634137.n4.nabble.com/Error-on-non-object-Pro-PHP-book-tp3335964p3335964.html Sent from the Zend Framework mailing list archive at Nabble.com.