CakeAdvent Day 4: Interactive command-line REPL for CakePHP
http://josediazgonzalez.com/2013/12/04/interactive-command-line-repl/ The latest post is up, and I write briefly about how to setup 3 different command-line interfaces for interactively running CakePHP code. If you are familiar with *irb* from Ruby, or *ipython* in the Python world, then this is something that may interest you! If you've missed the lineup thus far, here it is: - Part 1 - Testing your CakePHP Plugins with Travishttp://josediazgonzalez.com/2013/12/01/testing-your-cakephp-plugins-with-travis/ - Part 2 - Fun with CakePHP Viewshttp://josediazgonzalez.com/2013/12/02/fun-with-cakephp-views/ - Part 3 - Hacking the CakePHP Dispatch Systemhttp://josediazgonzalez.com/2013/12/03/hacking-the-cakephp-dispatch-system/ - Part 4 - Interactive command-line REPL for CakePHPhttp://josediazgonzalez.com/2013/12/04/interactive-command-line-repl/ As always, feel free to comment here or there :) Jose -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: dd-mm-yyyy datetime format in input/datepicker field reverts to default format on refresh after error
I think I've found a solution, or it might be a hack - keen to get confirmation or advice (and apologies for the noobness in advance).. At the bottom of the add function of the ModelController.php, I've added the following code to check if the request data for the date field exists (when the page errors, the post data is being returned in the request data), and if it does to format it in the format I'm working with. It's doing the job, but I'd like to work out how I can make this a bit more generic as I have a few date fields throughout my project. //On load or refresh of the add view, check if request data is set for date fields, then format the output in to specific date formatif (isset($this-request-data['Model']['issue_date'])) { $this-request-data['Model']['issue_date'] = date('d-m-Y', strtotime($this-request-data['Model']['issue_date']));} I've used the same snippet on my edit function also (successfully), so that when a user goes to edit the record, the date is rendered in the input field in the correct format. On Monday, 2 December 2013 22:50:01 UTC+11, seba wrote: A well-worn topic I'm sure.. Some background: *In the /View/Model/add.ctp view*, I have a few of datetime fields that use the Bootstrap datepicker and (successfully) sets the format of the dates in the text inputs in dd-mm- format: *Example of a datetime field input:* echo $this-Form-input('Model.issue_date', array( 'fieldset' = false, 'label' = false, 'before' = 'label class=col-sm-2 control-labelIssue Date/labeldiv class=col-sm-10', 'after' = '/div', 'class' = 'form-control datepicker', 'type' = 'text', 'div' = 'form-group' ) ); *Datapicker js at bottom of /View/Model/add.ctp:* script type=text/javascript !-- //-- $(document).ready(function() { $('.datepicker').datepicker({ format: dd-mm-, todayBtn: linked, orientation: bottom right, autoclose: true, todayHighlight: true }); }); /script *In my /Controller/ModelController.php file*, prior to saving the post/form data, I convert the field in to mysql format: if (isset($this-request-data['Model']['issue_date'])) { $this-request-data['Model']['issue_date'] = date('Y-m-d H:i', strtotime($this-request-data['Model']['issue_date'])); } *And in the /Model/Model.php* file I have basic validation to ensure the field isn't empty (i've removed validating datetime format temporarily): 'issue_date'= array( 'allowEmpty' = array( 'rule'= 'notEmpty', 'message' = 'Please enter a date and time' ), *Problem 1:* When I add datetime validation to the field in the /Model/Model.php file, I get a format validation error. Here's the code I use to validate the format (one of many permutations used): 'issue_date'= array( 'allowEmpty' = array( 'rule'= 'notEmpty', 'message' = 'Please enter a date and time' ), 'format' = array( 'rule' = array('datetime', 'dmy'), 'message' = 'Please enter a valid date' ) ), When I remove the date format validation, the form posts fine, and the (correct) datetime is committed to the datavase. *Problem 2:* When I encounter an error on the form, like the one in Problem 1, above, and return back to the add or edit views, the dates in the text input fields revert back to -mm-dd H:i:s format, and I have to reselect the date from the datepicker to return back to dd-mm- format. I figure I need to add beforeRender to check if a post value exists for the date field, and if so to format it, but I have a feeling there's something potentially a lot simpler I could be doing to manage both of these issues, and am keen to see/hear some opinions/advice. Thanks in advance! -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
PLUGIN WHICH MODIFIED FILE
Hello, I just wondering how can a plugin modified some files. Here is the case. Let's say I have menu.ctp and have a form (form A). Then I build a plugin. How can I make this plugin insert new menus to the current file (menu.ctp)? Then, how can I make this plugin to add some additional fields to the form A, automatically? Or it just limited to hard-code? If there are another approaches are welcome. Thank you. -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
CakeSocket - Allowed memory size of bytes exhausted error
Hi, I need help, I tried to send email with CakeEmail and I received this error: Error: Allowed memory size of 134217728 bytes exhausted ... File: /cakephp/2.2/lib/Cake/Network/CakeSocket.php Line: 199 What could cause this error? Thank -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: CakeSocket - Allowed memory size of bytes exhausted error
On Wednesday, 4 December 2013 17:29:28 UTC+1, Sebastien Beausoleil wrote: Hi, I need help, I tried to send email with CakeEmail and I received this error: Error: Allowed memory size of 134217728 bytes exhausted ... File: /cakephp/2.2/lib/Cake/Network/CakeSocket.php Line: 199 What could cause this error? The script running out of memory? AD -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Virtual Field + Concat and find problems
Hi everyone, i have a table clients wich the model is Client... and in my table I have the fields city and state and others... Also I have the following virtualfield: public $virtualFields = array( 'local'=CONCAT(Client.city,' - ',Client.state), ); When i use a find all with the conditions 'Client.local'='Cascavel - PR' it works perfectly... but if I try to find with the conditions 'Client.local'=array('Cascavel - PR','Toledo - PR'), cake gives me an error saying that the field Client.local doesnt exists... Does anyone know where i am wrong?? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: CakeSocket - Allowed memory size of bytes exhausted error
Yes -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Virtual Field + Concat and find problems
You cannot search a virtualField... it is virtual. You'll have to search the columns directly. On Thu, Dec 5, 2013 at 3:17 AM, André Luis cavall...@live.com wrote: Hi everyone, i have a table clients wich the model is Client... and in my table I have the fields city and state and others... Also I have the following virtualfield: public $virtualFields = array( 'local'=CONCAT(Client.city,' - ',Client.state), ); When i use a find all with the conditions 'Client.local'='Cascavel - PR' it works perfectly... but if I try to find with the conditions 'Client.local'=array('Cascavel - PR','Toledo - PR'), cake gives me an error saying that the field Client.local doesnt exists... Does anyone know where i am wrong?? -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out. -- Simon Males -- Like Us on FaceBook https://www.facebook.com/CakePHP Find us on Twitter http://twitter.com/CakePHP --- You received this message because you are subscribed to the Google Groups CakePHP group. To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.