Re: Uploaded Form Helper: FormationHelper
Looks promising, I think that you can avoid $data parameter, it must be accessible in the helper through $this-params['data'] (because HtmlHelper needs it) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: radio button select
a thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
mmm..but I think that $this-params['data']=$data; is standard, see first blog tutorial of wiki, edit() action: http://wiki.cakephp.org/tutorials:blog_tutorial_-_1?s=params+data function edit($id=null) { if (empty($this-params['data'])) { $this-Post-id = $id; $this-params['data'] = $this-Post-read(); $this-render(); } else { if ( $this-Post-save($this-params['data']['Post'])) { $this-flash('Your post has been updated.','/posts'); } } } In newer versions of cake, $this-data at controller is used instead, I think that $this-data doesn't work in this case --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
Ok now I'm documented. If you use $this-params['data']=$data at your controller, then in the helper is accessible through $this-params['data'] If you use $this-data at your controller, then in the helper $this-data The correct way is to check where is the data. From HtmlHelper: function tagValue($fieldName) { $this-setFormTag($fieldName); if (isset($this-params['data'][$this-model][$this-field])) { return h($this-params['data'][$this-model][$this-field]); } elseif(isset($this-data[$this-model][$this-field])) { return h($this-data[$this-model][$this-field]); } return false; } You can use HtmlHelper in your own helper, and doing $value=$this-Html-tagValue($fieldName) you will get the correct value --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: HasMany relationship and select conditions
Is there really nobody who has ever come across this problem? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
You don't need to pass $data to the helpers: see the blog tutorial edit action: function edit($id = null) { if (empty($this-data)) { $this-Post-id = $id; $this-data = $this-Post-read(); } else { if ($this-Post-save($this-data['Post'])) { $this-flash('Your post has been updated.','/posts'); } } } You always have $this-data at controller, then in your helper (including the html helper) you can do $value=$this-Html-tagValue($fieldname) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: creating a selectTag from an enum in the model
I've been dealing with the same issue. If you use scaffolding, it works just fine, producing a very nice select box. If you use bake.php, it produces LOT'S of errors. Shold be consistent. It seems like there should be something in the manual about dealing with verious column types. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
be careful, you're only using $this-data at helper, but it only works if you put $this-data in controller. There's two ways at controller to set the data, $this-data or $this-params['data']. You must check these two at your helper for ensure compatibility to all the users (if this is what you want). I repeat, use $value=$this-Html-tagValue($fieldName) for maximum compatibility --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: HasMany relationship and select conditions
It sounds like you should use bindModel in the controller, and set a variable for the conditions key in the hasMany Instructor array. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: othAuth and default sessions
What is CAKE_SECURITY set to in core.php? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
RE: Uploaded Form Helper: FormationHelper
[mailto:[EMAIL PROTECTED] On Behalf Of RosSoft I repeat, use $value=$this-Html-tagValue($fieldName) for maximum compatibility Thanks for the pointer. I actually ended up copying the HtmlHelper code into FormationHelper and modifying it, because tagValue was calling h() (AKA htmlspecialchars() ) on the value, which escapes HTML entities. Since I am using my database to store HTML text, that's not what I wanted. But the latest version of my posted code supports both $this-params['data'] and $this-data. Regards, Ryan --- Ryan Ginstrom [EMAIL PROTECTED] / [EMAIL PROTECTED] http://ginstrom.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Please help with Ajax controller method
Here's how I solved the problem: /app/controllers/test_controller.php ?php class TestController extends AppController { var $uses = array(); var $layout = 'test'; var $helpers = array('Html', 'Javascript'); var $components = array('Json'); function index() { } function getText() { $this-set('text', $this-Json-encode(array('text' = 'Hello World!'))); $this-render('json', 'ajax'); } } ? /app/views/layouts/test.thtml !DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd; html xmlns=http://www.w3.org/1999/xhtml; head ?php print $html-charsetTag('UTF-8') ? ?php print $javascript-link('prototype') ? /head body ?php echo $content_for_layout ? /body /html /app/views/test/index.thtml pThe text below is retrieved asynchronously from the server:/p div id=sometext/div script type=text/javascript // ![CDATA[ new Ajax.Request('?php echo $html-url('/test/getText'); ?', {onSuccess:displayText}); function displayText(response, json) { document.getElementById('sometext').innerHTML = json.text; } // ]] /script /app/views/test/json.thtml ?php header(X-JSON: $text); ? I'm using the JsonComponent I just added to snippets: http://cakeforge.org/snippet/detail.php?type=snippetid=74 To use JsonComponent you also need the JSON-PHP library JSON.php in your /vendors directory. So basically in client-side javascript an Ajax.Request calls the getText action in TestController, which creates a PHP array of some text and uses the JsonComponent to encode it in JSON format. That action then renders a json view that just sends a X-JSON header with the JSON text. Then back on the client-side, the onSuccess handler gets a 2nd argument that Prototype magically sticks the JSON data in. You can then use that json object to display the data you got from the server. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Problems w/ Cake Tutorials Working.. Getting Fatal Errors
I tried what you suggested above and only got this line (which I don't understand) Parse error: parse error, unexpected T_VAR in /jobboard.bernardtransportation.com/CAKE/app/app_controller.php on line 42 Both the tasks and gallery are tutorials which I did not change the code at all. I am just trying to learn CAKE, but haven't learned much so far and have been terribly frustrated. I don't know what to try next. I tried the URL for gallery that you suggested above, but still got the same old Fatal Error message, nothing changed. Thank you so much for trying to help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
I've also been working on a similar form helper. I just uploaded it at: http://cakeforge.org/snippet/detail.php?type=snippetid=75 It extends Cake's Form helper and also takes the validation from the model (using the advanced validation method - multiple rules per field) so you don't have to retype the validation messages or which fields are required, in your view. It's still a work in progress and requires a few other components (the advanced validator, and error helper), but maybe we can learn from each other and get a really good form helper out there. I'm all for as little typing as possible! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Problems w/ Graham Bird's Task List Tutorial
I am having problems trying to place the correct URL that Graham states in his tutorial for the AJAX task list for done.thml: If Cake is installed in a subfolder (ie not your server's web root) then you will need to use $html-url(/tasks/undo/ . $item[id] ); in the second Ajax.Updater argument. This means the URL is generated by Cake rather than being hard-coded. I am too inexperienced to fully understand what the correct URL would be and where I would place my URL in this code with the correct characters : div id=todo_view p class=file-timeRendered: ?=gmdate('H:i:s', time())? GMT/p p class=file-nameView: /app/views/tasks/todo.thtml/p ?php foreach ($data as $row) { $item = $row['Task']; if ($item['done'] == 0) { print 'div class=task id=todo_' . $item['id'] . ' title=' . $item['id'] . ''; print 'input id=todo_check' . $item['id'] . ' type=checkbox onClick=new Ajax.Updater(\'tasks_done\',\'/tasks/done/' . $item['id']. '\', {asynchronous:true, evalScripts:true});new Effect.Fade(\'todo_' . $item['id'] . '\'); / '; print 'label for=todo_check_' . $item['id'] . '' . $item['title'] . '/label'; print '/div' . \n; } } ? /div And, if I have CAKE installed here: http://jobboard.bernardtransportation.com/CAKE/tasks What URL would I use so that done.thtml can be found by todo.thtml? Please help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: insert id after save?
either perform $this-Comment-save($this-data) and then refernece $this-Comment-id -OR- if you have your associations setup in the models you can have $this-data['Comment'] and $this-data['Comment_Association'] all saved via $this-Comment-save($this-data) (that second method probalby isn't what your'e trying to do here with the comments, but just letting you know that you can save multiple data models at once) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: How optimize application?
I just stumbled onto this post by chance, and persistModel looks very interested, but i can't really find it covered in any docs - If you're using model caching in this fashion, how do you control when/how-often the model cache gets refreshed? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: updating a record
basically you'd want to set $this-data['Model']['user_id'] = $this-Session-user_id (I forget correct Session syntax at the moment, but you ge tthe idea) - do this before your $this-Model-save($this-data) statement in your controller's add or edit methods in your Edit method do pretty much what you were saying - before you load the Model's data into your edit form, when you're querying the Model to populate, add something like '`Model`.`user_id` = {$session_user_id}' to your find() statement take a look at rdBloggery - http://rd11.com/rdOS/ - it uses a simple but handy authentication / permissions schema (rdAuth) and answers a lot of questions like yours --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Problems w/ Cake Tutorials Working.. Getting Fatal Errors
? class AppController extends Controller { // } this brace is not necessary var $helpers = array('Html','Javascript','Ajax'); } // lacking a curly brace ? ? On 6/12/06, jeannie109 [EMAIL PROTECTED] wrote: Here is the URL: http://cakephp.org/pastes/show/2fde1e708150e1046c472674853e9879 -- [web] http://synapsisdi.com.br [livesets] http://djspark.com.br --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Problems w/ Cake Tutorials Working.. Getting Fatal Errors
Thank you so much! Problem solved. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Errors when using bake.php
Thanks to everyone in advance. When I am using bake.php- i keep getting these error when it trys to write out the config info for the db: php bake.php -app /var/www/si/testapp Creating file /var/www/si/cake///var/www/si/testapp/config/database.php br / bWarning/b: fopen(/var/www/si/cake//var/www/si/testapp/config/database.php): failed to open stream: No such file or directory in b/var/www/si/cake/cake/scripts/bake.php/b on line b1434/bbr / Error! Couldn't open //var/www/si/testapp/config/database.php for writing. br / bWarning/b: main(/var/www/si/cake///var/www/si/testapp/config/database.php): failed to open stream: No such file or directory in b/var/www/si/cake/cake/scripts/bake.php/b on line b173/bbr / --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
RE: Uploaded Form Helper: FormationHelper
[mailto:[EMAIL PROTECTED] On Behalf Of brandags Wait - but don't I still need to send the validation rules, etc. to the view? Can you change what parameters are sent to the startup() function? Well, here is your init function: function init($validations=null, $data=null) { $formData = array('validations' = $validations, 'data'=$data); $this-controller-set('formData', $formData); } And you are calling it like this: function beforeFilter() { $this-Myform-controller = $this; $this-Myform-init($this-User-validate, $this-data); } So you should be able to do this: // seemed to work with preliminary testing... function startup( $controller ) { $validations = array() ; foreach( $controller-modelNames as $model ) { $validations += $controller-$model-validate ; } $this-controller = $controller ; $this-controller-set( 'formData', array( 'validations' = $validations, 'data' = $this-controller-data ) ) ; } -- Regards, Ryan Ginstrom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: How optimize application?
with debug set to zero doesn't CakePHP cache the model views for 24 hours at a time? So, once you went live it is going to cache the model for 24 hours at a time. And if you don't need those models then why are you making associations for them? You need to be careful using bindModel all over the place. Cause then instead of CakePHP building the association for use later it has to build it for each request you make. You can save yourself on the actual query by using the $recursive parameter. This will limit the SQL query to just the model (table) you are working on if set to zero. Also, Nate if you persist a model this would make the cache files permanent? So, only if you made field or association changes in the tables themselves would you need to clear the TMP\cache\model to have them rebuilt? (Or call it with the CakePHP clearcache method. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
One application, different views for each virtual host
Hi, I want to have one CakePHP application serving several sites. Each site has its own virtual host. I want each site to have its own look. I have done this before in Smarty by simply setting the template directory and the compiled-template directory. Something like this: class AppSmarty extends Smarty { function AppSmarty() {// Constructor $this-template_dir = 'templates/' . $_SERVER['SERVER_NAME']; $this-compile_dir = 'templates_c/' . $_SERVER['SERVER_NAME']; } } How can I do something similar in Cake? I know I can explicitly render a particular view in a controller action. But is there an easier way? And what about: - /app/views/pages/home.thtml - /app/views/layouts/default.thtml. And is there a caching issue to take into account/? Thanks, Mike --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: How optimize application?
I gotcha - makes sense; How would you go about clearing the persistModel cache? Out of curiousity is there any query caching built in / being built in to cake? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Uploaded Form Helper: FormationHelper
Wow, that is awesome. Thank you. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: How optimize application?
Yes, we're working on a very sophisticated query cache system for 2.0. Right now we just have some basic optimizations, i.e. if the same query is executed more than once, Cake will return the in-memory result. You can disable this on a per-model basis by setting var $cacheQueries = false. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: One application, different views for each virtual host
Yeah, there's a variable in Controller called $themeWeb that you can set, which will automatically pull assets from a different subdirectory of your webroot. I'm acutally not too sure on the details. PhpNut? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
What is $this-Post-User-set(....) in rdBloggery
I studying the rdBloggery. In a PostsController there is $this-Post-User-set(...); Is't Ok for the PostsController call the wiew Post but I don't anderstand how the Post model call the User model ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: othAuth and default sessions
It's the default of define('CAKE_SECURITY', 'high'); are there docs explaining just what each setting means? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: othAuth and default sessions
change it to 'medium' then see what happens. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
getting sum of a column for one field
hi all, last night I came up with a generic function to be able to get the sum of the numeric values of certain rows. I am wondering if there was not an easier solution than mine. Feedback and improvement would be greatly appreciated :) so here it is (I put it in app_model.php so it ios available to all models) : code /** * Returns the sum of rows for a given field * the function accepts limitation in number or conditions or both (like findAll) * * @param mixed $conditions SQL conditions as a string * @param mixed $field name of the field that is to be used for the summing operation * @param string $order SQL ORDER BY conditions (e.g. price DESC or name ASC) * @param int $limit SQL LIMIT clause, for calculating items per page. * @param int $page Page number, for accessing paged data * @return float the result of the addition */ function getSumForField($conditions = null, $field = null, $alias = null, $order = null, $limit = null, $page = 1) { $offset = null; if($conditions == null) $conditions = 1=1; if ($page 1 $limit != null) { $offset = ($page - 1) * $limit; $limitClause = LIMIT . $limit . , . $offset; } else { $limitClause = ; } if($order != null) { $orderClause = ORDER BY . $order; } else { $orderClause = ; } $rs = $this-query(SELECT SUM(` . $field . `) AS . $alias . FROM . (SELECT ` . $field . ` FROM . $this-table . AS . $this-name . WHERE . $conditions . $orderClause . $limitClause .) . AS `table`); return $rs[0][0][$alias]; } /code in your controller: code $field = 'items_paid'; $alias = 'total' . Inflector::camelize($field); $result = $this-{$this-modelClass}-getSumForField(null,$field,$alias,$this-order,$this-show,$this-page); //set the variable to be used in a view $this-set($alias, $result); /code hope this is useful or just good for discussion thomas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: New JavaScript Features
Sounds interesting, Thanks for the heads up! :-) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Errors when using bake.php
Did you setup your database file to connect? http://manual.cakephp.org/chapter/4 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Please help with Ajax controller method
The point of the original post (and my solution) was to send JSON formatted data back to the client, not just HTML to be inserted in a div. Maybe I should've created a less trivial example... Anyhow my original solution wasn't good, the json.thtml view should be: /app/views/test/json.thtml ?php echo $text; ? instead of sending X-JSON headers, there appears to be a limit as to how much data you can stuff in a header. So then you also need a JSON decoder on the javascript side (unless you trust your data, then just do an eval()) - just use the one at http://www.json.org/js.html. So if you just wanted the controller method called once instead of repeatedly, is that what AjaxHelper::remoteFunction() method does? Does it just generate a Prototype Ajax.Request? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Re: Please help with Ajax controller method
Personally, I think putting JSON data in the header is a poor solution, especially when you consider that all Prototype adds is doing the eval( ) for you. It's better to just embed the data in your own custom JS code. And yes, AjaxHelper::remoteFunction is used to generate Ajax.Request and Ajax.Updater calls. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---
Proof of concept: Custom validation using beforeValidate
I really like the idea of custom validation error messages. For example, for a password field you could check that the password was entered the same way twice, contains at least two numbers, no illegal characters, etc., and give a different error message for each. I think that validation should live in the model, so error messages should as well. Thus, I put together a quick proof of concept using beforeValidate(). Comments/critiques appreciated. First, in the model, define a beforeValidate function: function beforeValidate() { $this-valMessages = array() ; $this-valMessages['modelValidationErrors'] = array( 'username' = 'This username is already taken. Please choose another' ) ; return false ; } Then, in app_controller, the following function: function validatingSave( $model ) { if ( $model-save( $this-data ) ) return true ; $this-Session-setFlash( 'p class=errorSorry, but we cannot process your form. Please make the changes indicated below, and try again./p', '' ); $this-data += $model-valMessages ; return false ; } Next, in the controller's edit function, change the save line to this: if ( $this-validatingSave( $this-Attachment ) ) { $this-Session-setFlash( 'p class=successYour profile has been updated./p', '' ); $this-redirect( /users ); } Now in your ErrorHelper, you should have access to $this-data['[modelValidationErrors]'] If it's set and the field is set, you can show the custom error message for that field, or if not, the fallback validation error message from HtmlHelper. Does this sound like a good direction to take my validation? Thanks for any feedback. -- Regards, Ryan Ginstrom --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Cake PHP group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php -~--~~~~--~~--~--~---