Re: Default controller when unspecified?
Look in app/config/routes.php and you will see default route. ("/") On Apr 26, 7:41 am, Opblah <[EMAIL PROTECTED]> wrote: > Hi, > > How do I specify a default controller for my site? If my domain > ishttp://www.mydomain.com, I want to be able to specify a certain > controller to use by default when going tohttp://www.mydomain.com(so > maybe it would be the same as going tohttp://www.mydomain.com/products > or something). I looked around > inhttp://manual.cakephp.org/view/49/controllers > but didn't see how to do it. > > I'm using version 1.2. > > Thanks, > Opblah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Association Frustration
Sounds like you're not setting the recursive level high enough. I'm guessing you're doing something like: $skateparks = $this->Skatepark->find('all'); Simple solution is to do: $this->Skatepark->recursive = 3; $skateparks = $this->Skatepark->find('all'); Better solution (but more involved) is using something like Bindable Behavior. http://bakery.cakephp.org/articles/view/bindable-behavior-control-your-model-bindings On Apr 26, 1:50 pm, Kyle Decot <[EMAIL PROTECTED]> wrote: > I am making a skatepark directory and I'm having some troubles with my > associations. I have: > > > class Skatepark extends AppModel { > > var $name = 'Skatepark'; > > var $validate = array('parkName' => VALID_NOT_EMPTY); > > var $hasMany = array("Comment","Photo"); > > } > > ?> > > > class User extends AppModel { > > var $name = 'User'; > > var $belongsTo = array("Comment","Skatepark"); > > var $hasMany = array("Comment"); > > } > > ?> > > > class Comment extends AppModel { > > var $name = "Comment"; > > var $belongsTo = array("Skatepark","User"); > > var $hasOne = array("User"); > > } > > ?> > > I think I am doing something wrong because I am not getting any > infomation about the user when looking at my comment information. > > [Comment] => Array > ( > [0] => Array > ( > [id] => 168 > [skatepark_id] => 1 > [user_id] => 1 > [comment] => I went to the dirty east bmx contest > this year and it was incredible! > [datePosted] => 2008-01-02 12:34:00 > ) > > [1] => Array > ( > [id] => 180 > [skatepark_id] => 1 > [user_id] => > [comment] => I absolutely love this skatepark. The > foam pit is great! > [datePosted] => -00-00 00:00:00 > ) > > ) > > Why am I not getting the user information in my array? I am fairly new > to hasOne,hasMany, belongsto, etc so I'm sure that it's something > simple. Thanks in advance for the help as always. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: a couple of small things I can't figure out
Hi Simon, this is what I have put in: view: create('Result');?> Subject Student Number Quiz Result "; echo ""; echo $form->input("Result.{$i}.subject", array('label' => '')); echo ""; echo ""; echo $form->input("Result.{$i}.student", array('label' => '')); echo ""; echo ""; echo $form->input("Result.{$i}.quiz", array('label' => '')); echo ""; } ?> end('Add results'); ?> controller: function add() { $this->Result->saveAll($this->data,false); } and here is the error that it gives (??): Warning (2): array_merge() [function.array-merge]: Argument #2 is not an array [CORE/cake/libs/model/model.php, line 1358] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Problem with OS X and .ctp files
Something totally noob coming up so beware! I've just started to use Mac OS X (Leopard) and I love it alot. I think I've also fallen in love with cakePHP though I havent done anything with it yet.. just tryied to read and learn. However today I finally had time and I downloaded cakePHP beta 1.2 and tried to do tutorial from cookbook. Everything went well till I had to create a .ctp file. Is it possible that my Leopard doesnt regognize that filetype at all because only way I can find .ctp files is Finders Spotlight, but I cant do anything to those. With basic browsing with Finder I cant see any .ctp files for example in /APP/views/pages or layouts but according to cakePHP startup page there should be home.ctp and default.ctp. I can see those with Spotlight but with Finder or Terminal.. nothing.. just xml, js and rss -folders. Because of this regognizing thingie I tried to do posts/index.ctp file just like in tutorial, but it doesnt save or read it correctly. I've been googling if I could find a solution but seems like I'm the only one with this.. am I? Does someone know the solution how get this solved so I can continue? Also if someone knows how to get Textmate handle these files correctly i Would preciate to get that information. Best Regards, iBob --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Default controller when unspecified?
Hi, How do I specify a default controller for my site? If my domain is http://www.mydomain.com, I want to be able to specify a certain controller to use by default when going to http://www.mydomain.com (so maybe it would be the same as going to http://www.mydomain.com/products or something). I looked around in http://manual.cakephp.org/view/49/controllers but didn't see how to do it. I'm using version 1.2. Thanks, Opblah --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: a couple of small things I can't figure out
thanks again b logica. Have tried what you have suggested with no luck. What I am passing is just an integer. I am passing this integer to the function so I know which student the file is for. I just had a thought that it might be easier to just pass the variable in the controller rather than in the form since it is already there, and isn't input by the user... something like this: function add($student = null) { if (!empty($this->data) && is_uploaded_file($this->data['Myfile']['File'] ['tmp_name'])) { $fileData = fread(fopen($this->data['Myfile']['File'] ['tmp_name'], "r"), $this->data['Myfile']['File'] ['size']); $this->data['Myfile']['name'] = $this->data['Myfile'] ['File']['name']; $this->data['Myfile']['type'] = $this->data['Myfile'] ['File']['type']; $this->data['Myfile']['size'] = $this->data['Myfile'] ['File']['size']; $this->data['Myfile']['data'] = $fileData; $this->data['Myfile']['student'] = $student; $this->Myfile->save($this->data); $this->flash('The file has been uploaded.', "/myfiles/view/ ${student}", 2); } } The file saves to the database, but nothing is saved under the 'student' field. also the 'flash' doesn't work correctly, and just redirects to '/myfiles/view/'. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Association Frustration
I am making a skatepark directory and I'm having some troubles with my associations. I have: VALID_NOT_EMPTY); var $hasMany = array("Comment","Photo"); } ?> I think I am doing something wrong because I am not getting any infomation about the user when looking at my comment information. [Comment] => Array ( [0] => Array ( [id] => 168 [skatepark_id] => 1 [user_id] => 1 [comment] => I went to the dirty east bmx contest this year and it was incredible! [datePosted] => 2008-01-02 12:34:00 ) [1] => Array ( [id] => 180 [skatepark_id] => 1 [user_id] => [comment] => I absolutely love this skatepark. The foam pit is great! [datePosted] => -00-00 00:00:00 ) ) Why am I not getting the user information in my array? I am fairly new to hasOne,hasMany, belongsto, etc so I'm sure that it's something simple. Thanks in advance for the help as always. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Undefined Variable: paginator
Hi Thanks for that, I have checked out your blog article, and I have also played around with the standard code, and I have found that if I use 'Message.message_status_id' => '<= 2' It works... So not sure how that does the job actually, but seems to be working.. Is there a reason why the paginate doesn't accept an SQL Query string like the findAll etc does? Seems like that would be a logical addition to it.. Thanks Patrick On Apr 26, 10:05 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > On Fri, Apr 25, 2008 at 9:30 PM, AussieFreelancer > > > > <[EMAIL PROTECTED]> wrote: > > > Right you are! :D Man I'm going crazy... passed the object to the view > > using $data = $this->paginate('Message'); and it started working :D > > Sorry for the hassle, thanks for the help :) > > > On a slightly side note, when it comes to adding conditions, I need > > the following condition: > > > 'Message.user_id = ' . $this->Auth->user('id') . ' AND > > Message.message_status_id IN (1, 2)' > > > How do I do this using the paginate variable? I have tried to pass it > > as the scope, and the userid works fine, but I cant seem to get the > > message_status_id part working. I need to use either IN() or an OR > > statement, but can't see how it is done... Is this possible? > > I have a posting on my blog about doing custom pagination, which is > exactly what you need. > > -- > Chris Hartjes > Internet Loudmouth > Motto for 2008: "Moving from herding elephants to handling snakes..." > @TheKeyBoard:http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Undefined Variable: paginator
On Fri, Apr 25, 2008 at 9:30 PM, AussieFreelancer <[EMAIL PROTECTED]> wrote: > > Right you are! :D Man I'm going crazy... passed the object to the view > using $data = $this->paginate('Message'); and it started working :D > Sorry for the hassle, thanks for the help :) > > On a slightly side note, when it comes to adding conditions, I need > the following condition: > > > 'Message.user_id = ' . $this->Auth->user('id') . ' AND > Message.message_status_id IN (1, 2)' > > How do I do this using the paginate variable? I have tried to pass it > as the scope, and the userid works fine, but I cant seem to get the > message_status_id part working. I need to use either IN() or an OR > statement, but can't see how it is done... Is this possible? > I have a posting on my blog about doing custom pagination, which is exactly what you need. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Undefined Variable: paginator
Right you are! :D Man I'm going crazy... passed the object to the view using $data = $this->paginate('Message'); and it started working :D Sorry for the hassle, thanks for the help :) On a slightly side note, when it comes to adding conditions, I need the following condition: 'Message.user_id = ' . $this->Auth->user('id') . ' AND Message.message_status_id IN (1, 2)' How do I do this using the paginate variable? I have tried to pass it as the scope, and the userid works fine, but I cant seem to get the message_status_id part working. I need to use either IN() or an OR statement, but can't see how it is done... Is this possible? On Apr 26, 8:46 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > On Fri, Apr 25, 2008 at 8:26 PM, AussieFreelancer > > <[EMAIL PROTECTED]> wrote: > > > Hi All, > > > I have just had a look through the groups, and tried a couple of > > things suggested, but for some reason I can't get the paginator > > working properly still. > > What about it isn't working? You getting errors? Pagination links > not showing up? Perhaps I don't understand pagination very well, but > I don't see where you are passing the paginator object to the view. > > -- > Chris Hartjes > Internet Loudmouth > Motto for 2008: "Moving from herding elephants to handling snakes..." > @TheKeyBoard:http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Sharing Codebase
Hmm, Looks like that could do the trick. I'll have to play around with that. Thanks On Apr 25, 6:04 pm, "Sam Sherlock" <[EMAIL PROTECTED]> wrote: > in bootstrap.php you can add additional paths - each project has its own > config settings also with paths to centrall models vendors and controllers > defined there > > http://groups.google.com/group/cakephp-edge/browse_thread/thread/2301... > > hth - S > On 25/04/2008, Steve <[EMAIL PROTECTED]> wrote: > > > > > Ok, > > > I'm developing an application and rather than installing it for each > > of my clients that are going to use it, I'd like for it to be > > installed on a single directory and have each client site able to > > access it. > > > The only thing that I want each client site to have unique is the > > following > > - Own database > > - Own webroot (obviously) > > - Own views > > > I know how to set it up where each client has their own webroot, but > > I'm not so sure how to set it up so that each client has their own DB > > and views. Further more, I would like for them to be able to use the > > default views, but with the capability to override them with their own > > views. Kind of like the way a Cake App can override views from the > > Cake core. > > > Any advise is appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Undefined Variable: paginator
$this->set('data', $this->Message->findAll('Message.user_id = ' . $this->Auth->user('id') . ' AND Message.message_status_id IN (1, 2)', null, 'Message.message_status_id, Message.importance, Message.created DESC')); should be something like $this->paginate['Message']['conditions']['Message.user_id'] = $this->Auth->user('id'); $this->paginate['Message']['conditions']['Message.message_status_id'] = 'IN (1, 2)'; $this->set('data', $this->paginate('Message')); On 26/04/2008, Chris Hartjes <[EMAIL PROTECTED]> wrote: > > > On Fri, Apr 25, 2008 at 8:26 PM, AussieFreelancer > <[EMAIL PROTECTED]> wrote: > > > > Hi All, > > > > I have just had a look through the groups, and tried a couple of > > things suggested, but for some reason I can't get the paginator > > working properly still. > > > > > What about it isn't working? You getting errors? Pagination links > not showing up? Perhaps I don't understand pagination very well, but > I don't see where you are passing the paginator object to the view. > > > -- > Chris Hartjes > Internet Loudmouth > Motto for 2008: "Moving from herding elephants to handling snakes..." > @TheKeyBoard: http://www.littlehart.net/atthekeyboard > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 Undefined Variable: paginator
On Fri, Apr 25, 2008 at 8:26 PM, AussieFreelancer <[EMAIL PROTECTED]> wrote: > > Hi All, > > I have just had a look through the groups, and tried a couple of > things suggested, but for some reason I can't get the paginator > working properly still. > What about it isn't working? You getting errors? Pagination links not showing up? Perhaps I don't understand pagination very well, but I don't see where you are passing the paginator object to the view. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Cake 1.2 Undefined Variable: paginator
Hi All, I have just had a look through the groups, and tried a couple of things suggested, but for some reason I can't get the paginator working properly still. This is my controller: ** CONTROLLER *** class MessagesController extends AppController { var $name = 'Messages'; var $helpers = array('Html', 'Form', 'Javascript', 'Ajax'); var $uses = array('Message'); var $paginate = array( 'Message' => array( 'limit' => 1, 'order' => array( 'Message.created' => 'desc', 'Message.message_status_id' => 'asc', 'Message.importance' => 'asc' ) ) ); function inbox() { $this->set('data', $this->Message->findAll('Message.user_id = ' . $this->Auth->user('id') . ' AND Message.message_status_id IN (1, 2)', null, 'Message.message_status_id, Message.importance, Message.created DESC')); } } * And then my view: ** VIEW *** Date sortKey() == 'created') { switch ($paginator->sortDir()) { case 'asc': $currDir = 'asc'; $newDir = 'desc'; break; case 'desc': $currDir = 'desc'; $newDir = 'asc'; break; } } else { $currDir = 'asc'; $newDir = 'desc'; } ?> ... * Is there any reason why this wouldn't be working? Everything seems to be as people suggest.. Any help would be greatly appreciated. :) Thanks Patrick --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Elementary Data Validation??
grigri, Thanks so much for taking time for such an in-depth reply. I particularly appreciated the help with the regular expressions. I am not very good at those! :) I would like to clarify that all of the fields do respond properly per the validation routines except the 'states' select field and the 'agreed_to_terms' checkbox. I did add 'allowEmpty' => false to each of my data validations but it made no change to any of the error messages. I also saw in the 1.2 manual (which is what I am working with) that the default value for 'allowEmpty' is false which is why I hadn't added it. I am still playing with the great form generation code you shared. I can see lots of ways to improve what I was doing. Any other suggestions are welcome. Thanks again! Jee --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: How to get JSON Response with AJAX link
here is a simplification of how I make json requests I am using jquery views/layouts/ajax.ctp header('Content-Type: text/x-json'); e(json_encode(Array('title' => $title_for_layout, 'content' => $content_for_layout))); webroot/js/common.js in a function that I attach to all links function callAllLinks(dataURL) { $.getJSON( dataURL, function (json){ console.info(json); } ); // /getJSON } $("a") .bind( 'click', {'href': this.href,'rel': this.rel}, function(event) { ... event.preventDefault(); callAllLinks(this.href); } ); hth - S On 25/04/2008, Tomka <[EMAIL PROTECTED]> wrote: > > > Hello. > > I try to get a JSON object as response of an AJAX request. > > The code in my view looks like this: > > echo $ajax->link("TEST", > array("controller" => "mycontroller", "action" => > "myjsonview"), > array("complete" => "testfunction(request, json);") > ); > > If I set the option "update" with an id of a div, I see the response: > a well formatted JSON-Object - so "myjsonview" seems to be coded > correctly. But how can a access this JSON-Object in my "complete"- > function? > > Thanks for help! > > > Tomka. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Sharing Codebase
in bootstrap.php you can add additional paths - each project has its own config settings also with paths to centrall models vendors and controllers defined there http://groups.google.com/group/cakephp-edge/browse_thread/thread/2301489ed8aa8044 hth - S On 25/04/2008, Steve <[EMAIL PROTECTED]> wrote: > > > Ok, > > I'm developing an application and rather than installing it for each > of my clients that are going to use it, I'd like for it to be > installed on a single directory and have each client site able to > access it. > > The only thing that I want each client site to have unique is the > following > - Own database > - Own webroot (obviously) > - Own views > > I know how to set it up where each client has their own webroot, but > I'm not so sure how to set it up so that each client has their own DB > and views. Further more, I would like for them to be able to use the > default views, but with the capability to override them with their own > views. Kind of like the way a Cake App can override views from the > Cake core. > > Any advise is appreciated. > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: renderElement strange behavior
You need to pass the data that you want to use in the element: $this->renderElement('browser_toolbar', $data_to_be_passed); In your case, it would be the $paginator object. -J. On Apr 25, 5:38 pm, rob5408 <[EMAIL PROTECTED]> wrote: > Sorry, most recent cake 1.2 > > On Apr 25, 5:25 pm, rob5408 <[EMAIL PROTECTED]> wrote: > > > I have a block of html/php i need to show twice on the page, so i > > thought i'd put it in an element. The content of the element is... > > > > > > > > > < Prev | Next > > td> > > > counter(array('format' => __('Displaying > > %start%-%end% of %count%', true))); ?> > > > Jump to page > > > $pages = range(0, $paginator->params['paging']['Photo'] > > ['pageCount']); unset($pages[0]); > > echo $form->input('page_selector', array('div' => '', 'label' => '', > > 'options' => $pages)); > > ?> > > > > > > > Select All | Select None > > > value="Publish Selected" /> > > > > > > > > > AND I display it with this in my view... > > > renderElement('browser_toolbar'); ?> > > > However, it will only show up if i have both the renderElement line > > ALONG with the element code, like this > > > renderElement('browser_toolbar'); ?> > > > > > > > > < Prev | Next > > td> > > > counter(array('format' => __('Displaying > > %start%-%end% of %count%', true))); ?> > > > Jump to page > > > $pages = range(0, $paginator->params['paging']['Photo'] > > ['pageCount']); unset($pages[0]); > > echo $form->input('page_selector', array('div' => '', 'label' => '', > > 'options' => $pages)); > > ?> > > > > > > > Select All | Select None > > > value="Publish Selected" /> > > > > > > > > > ...making it appear twice. If I remove the non-renderElement lines, an > > error occurs which makes my page just turn empty and white. I know the > > code in the element works because when they are there together, they > > both display fine. What am i missing? It must be small and/or stupid > > or i'm going crazy. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Sharing Codebase
Ok, I'm developing an application and rather than installing it for each of my clients that are going to use it, I'd like for it to be installed on a single directory and have each client site able to access it. The only thing that I want each client site to have unique is the following - Own database - Own webroot (obviously) - Own views I know how to set it up where each client has their own webroot, but I'm not so sure how to set it up so that each client has their own DB and views. Further more, I would like for them to be able to use the default views, but with the capability to override them with their own views. Kind of like the way a Cake App can override views from the Cake core. Any advise is appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: renderElement strange behavior
Sorry, most recent cake 1.2 On Apr 25, 5:25 pm, rob5408 <[EMAIL PROTECTED]> wrote: > I have a block of html/php i need to show twice on the page, so i > thought i'd put it in an element. The content of the element is... > > > > > < Prev | Next > td> > > counter(array('format' => __('Displaying > %start%-%end% of %count%', true))); ?> > > Jump to page > $pages = range(0, $paginator->params['paging']['Photo'] > ['pageCount']); unset($pages[0]); > echo $form->input('page_selector', array('div' => '', 'label' => '', > 'options' => $pages)); > ?> > > > > Select All | Select None > value="Publish Selected" /> > > > > > AND I display it with this in my view... > > renderElement('browser_toolbar'); ?> > > However, it will only show up if i have both the renderElement line > ALONG with the element code, like this > > renderElement('browser_toolbar'); ?> > > > > < Prev | Next > td> > > counter(array('format' => __('Displaying > %start%-%end% of %count%', true))); ?> > > Jump to page > $pages = range(0, $paginator->params['paging']['Photo'] > ['pageCount']); unset($pages[0]); > echo $form->input('page_selector', array('div' => '', 'label' => '', > 'options' => $pages)); > ?> > > > > Select All | Select None > value="Publish Selected" /> > > > > > ...making it appear twice. If I remove the non-renderElement lines, an > error occurs which makes my page just turn empty and white. I know the > code in the element works because when they are there together, they > both display fine. What am i missing? It must be small and/or stupid > or i'm going crazy. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
renderElement strange behavior
I have a block of html/php i need to show twice on the page, so i thought i'd put it in an element. The content of the element is... < Prev | Next > counter(array('format' => __('Displaying %start%-%end% of %count%', true))); ?> Jump to page params['paging']['Photo'] ['pageCount']); unset($pages[0]); echo $form->input('page_selector', array('div' => '', 'label' => '', 'options' => $pages)); ?> Select All | Select None AND I display it with this in my view... renderElement('browser_toolbar'); ?> However, it will only show up if i have both the renderElement line ALONG with the element code, like this renderElement('browser_toolbar'); ?> < Prev | Next > counter(array('format' => __('Displaying %start%-%end% of %count%', true))); ?> Jump to page params['paging']['Photo'] ['pageCount']); unset($pages[0]); echo $form->input('page_selector', array('div' => '', 'label' => '', 'options' => $pages)); ?> Select All | Select None ...making it appear twice. If I remove the non-renderElement lines, an error occurs which makes my page just turn empty and white. I know the code in the element works because when they are there together, they both display fine. What am i missing? It must be small and/or stupid or i'm going crazy. Any ideas? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Email Attachments Don't Work (1.2)
For anyone else suffering this problem the solution is: For some reason Cake won't do attachments unless you state the filePaths first. This is the case even if you are using an absolute path for your attachments. Thanks. On Apr 21, 2:47 pm, Doug <[EMAIL PROTECTED]> wrote: > I've done a scount round the group for info on this but not found any > help. One person wasn't answered - I hope that won't be the case this > time round. > > Basically I'm attempting to send an email with attachment. Using this > code: > //@todo Send from client email address > $this->Email->to = '[EMAIL PROTECTED]'; > $this->Email->subject = 'Something'; > $this->Email->replyTo = $client['Client']['email']; > $this->Email->from = $client['Client']['email']; > $this->Email->sendAs = 'html'; > $this->Email->attachments = array('/home/username/ > article_button.png'); > if($this->Emailer->send('Testing', null, null)){ > die('Email Sent!'); > }else{ > die('Failed to send email'); > } > > It dies with "Email Sent" and I do get the email in my inbox. However > there's no attachment. Anyone got any ideas? I've checked > permissions on the file and chmodded them to 777. No luck there. > > Hoipe you can help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: save() keeps creating new records, not updating old ones
So I finally figured this out. Here is the solution: Above this call in the if statement: $this->Profile->Info->save($this->data) you need to enter: $this->Profile->Info->setId( $temp['Info']['id'] ); Thanks for both your help and time. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Redirect path problem in production setup
Problem: I am moving a site from a Cake 1.1 development configuration to a production configuration in a shared hosting environment. I am using mod_rewrite. I can display pages successfully using the url http://www.domain_name.com/controller/action and also using http://www.domain_name.com/index.php?url=controller/action However, when my application reaches a $this->redirect('controller/ action') I receive a 404 page not found. The Apache error log shows a File Does Not Exist error with a path of /home/virtual/site62/fst/ home/action where action was the action from the URL. I have confirmed the controllers and views exist -- in fact the controllers are the same controllers I can reach successfully without a redirect. I have had this site running successfully in a development configuration on both Windows XP and on a different Linux hosting service. I have taken the following steps in trying to move to a production configuration: 1. Moved the contents of webroot to the /public_html folder 2. Moved the contents of the cake and app directories to /home/cake and /home/app respectively. 3. Updated index.php so that ROOT is defined as '/home' ; APP_DIR is defined as 'app' and 'CAKE_CORE_INCLUDE_PATH' is defined as '/home/ cake' . I have removed the index.php and .htaccess files that were in the cake and app directories, but still have .htaccess in the /public_html folder and it reads as follows: Action php5-script /interpreters/php5-script AddHandler php5-script .php RewriteBase / Options -MultiViews RewriteEngine On RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^(.*)$ index.php?url=$1 [QSA,L] Any help would be greatly appreciated. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Validation problem in CakePHP 1.2
Hey everyone! I'm a major newb to CakePHP only been using it for 2 weeks now and I've run into a little trouble with some validation. I've got a user registration page that I'm trying to create finally got the check between passwords to work thanks to Chris Hartjes' tutorial on user registration on his blog http://www.littlehart.net/atthekeyboard/2008/01/22/simple-user-registration-in-cakephp-12-part-ii/ Anyways, using his techniques also introduced something else I wasn't doing before using the Auth component. Which is great, I would of needed it anyways... problem is now if somebody does something wrong (puts in a duplicate username, passwords don't match, uses wrong characters for something, etc.) it displays my splash message "You've been registered! You can log in now." and redirects to the login page. Nothing has been added to the database because it didn't pass validation, but it also didn't go back to the /users/register page like it used to to display the errors. I've got to go to work for right now, but I'll come back and post my code so that you guys can take a look at it. I was just hoping that maybe someone knew what was going on and could help. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
How to get JSON Response with AJAX link
Hello. I try to get a JSON object as response of an AJAX request. The code in my view looks like this: echo $ajax->link("TEST", array("controller" => "mycontroller", "action" => "myjsonview"), array("complete" => "testfunction(request, json);") ); If I set the option "update" with an id of a div, I see the response: a well formatted JSON-Object - so "myjsonview" seems to be coded correctly. But how can a access this JSON-Object in my "complete"- function? Thanks for help! Tomka. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 final release date
I'll add that, with the changes that have occurred *within* the 1.2 branch itself, it seems odd that we're not looking at a 2.0 release. IMO, 1.2 should have been released long ago with many of the current changes moved into a 2.0 target branch. And, yes, I realise that development is never as tidy as all that. I'm sure it couldn't be helped without releasing a dodgy 1.2. That is, I'm confident the devs had very good reasons to go ahead with all the changes within 1.2. I'm not complaining, just commenting on the very significant changes since the first 1.2beta became available. In any case, I don't really care what no. release it is--it's all tasty stuff :-p On Fri, Apr 25, 2008 at 1:06 PM, seb <[EMAIL PROTECTED]> wrote: > > > And looking at the bug list in trac, I wouldn't say there are any > > major changes in the pipeline either. Going from 1.1 to 1.2 isn't > > totally trivial, so the sooner you get started on such a transition > > the better. If you are waiting for a "final" release before making > > that change, I would re-think the strategy, and instead just go with > > the current build. > > Well, I've been working with 1.2 beta since a while now. Since the very > beginning in fact. Changes from 1.1 to 1.2 were so important that after > 2 days learning 1.1, I switched to 1.2 even there was no "official" doc > yet. New Cookbook is nice and a good way to start learning :D > > I've got a website working with 1.2 beta nicely and I'm currently > working on a total recode of my good old (and rather badly coded) PHP4 > webstore > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
One should get in the habit of always using single quotes unless there is a variable inside that should be parsed (and, if so, it should be wrapped with { and } to at least make it obvious). Using double quotes without variables is wasting parse cycles. On Fri, Apr 25, 2008 at 10:08 AM, seb <[EMAIL PROTECTED]> wrote: > > rtanz wrote: > > cheers that worked perfectly, another thing while we're at it, i am > > noticing that the code works the same whether you use single or double > > quotes, is one or the other better? Sorry might be a php thing and > > nothing related to cake, im not an expert in php itself either. thanks > > Using single or double quotes does not change anything. Both are string > delimiters. > > *BUT* if you use double quotes you'll be able to escape some more sequences. > > Have a look at : > > > http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.single > > > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: order a find('list')?
Thanks a bunch. And I'm going to bookmark the book site. (Now, if someone would only remove that irritating hover style change on the code blocks ...) On Fri, Apr 25, 2008 at 1:11 PM, <[EMAIL PROTECTED]> wrote: > > http://book.cakephp.org/view/449/find > > > On Apr 25, 9:03 am, "b logica" <[EMAIL PROTECTED]> wrote: > > omg that was so freaking obvious! I'd been trying all sorts of things; > > that never occurred to me. > > Thanks a bunch! > > > > > > On Fri, Apr 25, 2008 at 1:53 AM, squawk <[EMAIL PROTECTED]> wrote: > > > > > Try this: > > > > > find('list', array('order'=> 'field')); > > > > > On Apr 24, 11:21 pm, "b logica" <[EMAIL PROTECTED]> wrote: > > > > cake_1.2.x.x_24.01.2008 > > > > > > I need to specify an order on a find('list') call and nothing I've > > > > tried is working :-( > > > > > > Is the new find() format documented anywhere? I can't even remember > > > > where I learned about it. Can 'list' be ordered? > > > > > > For the interested, here's the relevant hunk of model.php: > > > > > > case 'list' : > > > > if (empty($query['fields'])) { > > > > $query['fields'] = > array("{$this->alias}.{$this->primaryKey}", > > > > "{$this->alias}.{$this->displayField}"); > > > > $keyPath = "{n}.{$this->alias}.{$this->primaryKey}"; > > > > $valuePath = > "{n}.{$this->alias}.{$this->displayField}"; > > > > $groupPath = null; > > > > } else { > > > > if (!is_array($query['fields'])) { > > > > $query['fields'] = > String::tokenize($query['fields']); > > > > } > > > > if (count($query['fields']) == 1) { > > > > $keyPath = > "{n}.{$this->alias}.{$this->primaryKey}"; > > > > $valuePath = '{n}.' . $query['fields'][0]; > > > > $groupPath = null; > > > > $query['fields'] = > array("{$this->alias}.{$this->primaryKey}", > > > > $query['fields'][0]); > > > > } elseif (count($query['fields']) == 3) { > > > > $keyPath = '{n}.' . $query['fields'][0]; > > > > $valuePath = '{n}.' . $query['fields'][1]; > > > > $groupPath = '{n}.' . $query['fields'][2]; > > > > } else { > > > > $keyPath = '{n}.' . $query['fields'][0]; > > > > $valuePath = '{n}.' . $query['fields'][1]; > > > > $groupPath = null; > > > > } > > > > } > > > > > > Believe me, I've tried! If it's impossible, I can always re-order the > > > > array when I get it. Or I could create a view in Postgres to keep any > > > > selects to this table ordered the way I want (it's a lookup table, > > > > basically, but order is important). But I'm curious is this can be > > > > done directly. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: version 1.2 scaffolding drop down.
As a general rule, I try to check php classes first then http://api.cakephp.org/1.2/classes.html to make sure I'm not being a dork and picking something that is going to bite me in the a$$ later ;) Sam D On Fri, Apr 25, 2008 at 10:36 AM, Jose Gomez <[EMAIL PROTECTED]> wrote: > > That did it. > Thanks so much! > > > > On 4/25/08, Samuel DeVore <[EMAIL PROTECTED]> wrote: > > > > I wonder if it might be that Model/ Models are reserved words > > > > Sam D > > On Fri, Apr 25, 2008 at 9:37 AM, JoC <[EMAIL PROTECTED]> wrote: > > > > > > Hello All, > > > before I get yelled at I tried all the solutions I found on here > > > before posting none of them worked. > > > I have the following structure and I can't get scaffolding to generate > > > a drop down of Manufacturers instead a get a text box. > > > > > > tables > > > > > > CREATE TABLE manufacturers ( > > > id smallint(6) NOT NULL auto_increment, > > > title varchar(50) NOT NULL, > > > PRIMARY KEY (id), > > > UNIQUE KEY `name` (title) > > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > > > > > CREATE TABLE models ( > > > id smallint(6) NOT NULL auto_increment, > > > manufacturer_id smallint(11) NOT NULL, > > > model varchar(50) NOT NULL, > > > voltage set('A/C','D/C') NOT NULL, > > > kw varchar(20) NOT NULL, > > > PRIMARY KEY (id), > > > KEY manufacturer_id (manufacturer_id) > > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > > > > > > > > > > > models > > > > > >> > class Model extends AppModel { > > > > > > var $name = 'Model'; > > > var $useTable = 'models'; > > > var $displayField = 'title'; > > > var $belongsTo = array( > > > 'Manufacturer' => array('className' => > 'Manufacturer', > > > > 'foreignKey' => 'manufacturer_id', > > > > 'conditions' => '', > > > 'fields' > => '', > > > 'order' > => '' > > > ) > > > ); > > > > > > } > > > ?> > > > > > >> > class Manufacturer extends AppModel { > > > > > > var $name = 'Manufacturer'; > > > var $useTable = 'manufacturers'; > > > var $displayField = 'title'; > > > > > > var $hasMany = array( > > > 'Model' => array('className' => 'Model', > > > > 'foreignKey' => 'manufacturer_id', > > > 'order' > => '' > > > ) > > > ); > > > > > > } > > > ?> > > > > > > controler: > > >> > { > > > var $scaffold; > > > } > > > ?> > > > > > > > > > > > > > > > > > > -- > > -- > > > (the old fart) the advice is free, the lack of crankiness will cost you > > > > - its a fine line between a real question and an idiot > > > > http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ > > http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ > > http://blog.samdevore.com/cakephp-pages/i-cant-bake/ > > > > > > > > > > -- > Jose C Gomez > Phone: 904-635-1996 > E-Mail: [EMAIL PROTECTED] > > > > > > -- -- (the old fart) the advice is free, the lack of crankiness will cost you - its a fine line between a real question and an idiot http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ http://blog.samdevore.com/cakephp-pages/i-cant-bake/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: version 1.2 scaffolding drop down.
That did it. Thanks so much! On 4/25/08, Samuel DeVore <[EMAIL PROTECTED]> wrote: > > I wonder if it might be that Model/ Models are reserved words > > Sam D > On Fri, Apr 25, 2008 at 9:37 AM, JoC <[EMAIL PROTECTED]> wrote: > > > > Hello All, > > before I get yelled at I tried all the solutions I found on here > > before posting none of them worked. > > I have the following structure and I can't get scaffolding to generate > > a drop down of Manufacturers instead a get a text box. > > > > tables > > > > CREATE TABLE manufacturers ( > > id smallint(6) NOT NULL auto_increment, > > title varchar(50) NOT NULL, > > PRIMARY KEY (id), > > UNIQUE KEY `name` (title) > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > > > CREATE TABLE models ( > > id smallint(6) NOT NULL auto_increment, > > manufacturer_id smallint(11) NOT NULL, > > model varchar(50) NOT NULL, > > voltage set('A/C','D/C') NOT NULL, > > kw varchar(20) NOT NULL, > > PRIMARY KEY (id), > > KEY manufacturer_id (manufacturer_id) > > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > > > > > > > models > > > > > class Model extends AppModel { > > > > var $name = 'Model'; > > var $useTable = 'models'; > > var $displayField = 'title'; > > var $belongsTo = array( > > 'Manufacturer' => array('className' => > > 'Manufacturer', > > > > 'foreignKey' => 'manufacturer_id', > > > > 'conditions' => '', > > 'fields' => > > '', > > 'order' => > > '' > > ) > > ); > > > > } > > ?> > > > > > class Manufacturer extends AppModel { > > > > var $name = 'Manufacturer'; > > var $useTable = 'manufacturers'; > > var $displayField = 'title'; > > > > var $hasMany = array( > > 'Model' => array('className' => 'Model', > > > > 'foreignKey' => 'manufacturer_id', > > 'order' => > > '' > > ) > > ); > > > > } > > ?> > > > > controler: > > > { > > var $scaffold; > > } > > ?> > > > > > > > > > > > -- > -- > (the old fart) the advice is free, the lack of crankiness will cost you > > - its a fine line between a real question and an idiot > > http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ > http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ > http://blog.samdevore.com/cakephp-pages/i-cant-bake/ > > > > -- Jose C Gomez Phone: 904-635-1996 E-Mail: [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: order a find('list')?
http://book.cakephp.org/view/449/find On Apr 25, 9:03 am, "b logica" <[EMAIL PROTECTED]> wrote: > omg that was so freaking obvious! I'd been trying all sorts of things; > that never occurred to me. > Thanks a bunch! > > On Fri, Apr 25, 2008 at 1:53 AM, squawk <[EMAIL PROTECTED]> wrote: > > > Try this: > > > find('list', array('order'=> 'field')); > > > On Apr 24, 11:21 pm, "b logica" <[EMAIL PROTECTED]> wrote: > > > cake_1.2.x.x_24.01.2008 > > > > I need to specify an order on a find('list') call and nothing I've > > > tried is working :-( > > > > Is the new find() format documented anywhere? I can't even remember > > > where I learned about it. Can 'list' be ordered? > > > > For the interested, here's the relevant hunk of model.php: > > > > case 'list' : > > > if (empty($query['fields'])) { > > > $query['fields'] = > > array("{$this->alias}.{$this->primaryKey}", > > > "{$this->alias}.{$this->displayField}"); > > > $keyPath = "{n}.{$this->alias}.{$this->primaryKey}"; > > > $valuePath = "{n}.{$this->alias}.{$this->displayField}"; > > > $groupPath = null; > > > } else { > > > if (!is_array($query['fields'])) { > > > $query['fields'] = > > String::tokenize($query['fields']); > > > } > > > if (count($query['fields']) == 1) { > > > $keyPath = > > "{n}.{$this->alias}.{$this->primaryKey}"; > > > $valuePath = '{n}.' . $query['fields'][0]; > > > $groupPath = null; > > > $query['fields'] = > > array("{$this->alias}.{$this->primaryKey}", > > > $query['fields'][0]); > > > } elseif (count($query['fields']) == 3) { > > > $keyPath = '{n}.' . $query['fields'][0]; > > > $valuePath = '{n}.' . $query['fields'][1]; > > > $groupPath = '{n}.' . $query['fields'][2]; > > > } else { > > > $keyPath = '{n}.' . $query['fields'][0]; > > > $valuePath = '{n}.' . $query['fields'][1]; > > > $groupPath = null; > > > } > > > } > > > > Believe me, I've tried! If it's impossible, I can always re-order the > > > array when I get it. Or I could create a view in Postgres to keep any > > > selects to this table ordered the way I want (it's a lookup table, > > > basically, but order is important). But I'm curious is this can be > > > done directly. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: version 1.2 scaffolding drop down.
I wonder if it might be that Model/ Models are reserved words Sam D On Fri, Apr 25, 2008 at 9:37 AM, JoC <[EMAIL PROTECTED]> wrote: > > Hello All, > before I get yelled at I tried all the solutions I found on here > before posting none of them worked. > I have the following structure and I can't get scaffolding to generate > a drop down of Manufacturers instead a get a text box. > > tables > > CREATE TABLE manufacturers ( > id smallint(6) NOT NULL auto_increment, > title varchar(50) NOT NULL, > PRIMARY KEY (id), > UNIQUE KEY `name` (title) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > CREATE TABLE models ( > id smallint(6) NOT NULL auto_increment, > manufacturer_id smallint(11) NOT NULL, > model varchar(50) NOT NULL, > voltage set('A/C','D/C') NOT NULL, > kw varchar(20) NOT NULL, > PRIMARY KEY (id), > KEY manufacturer_id (manufacturer_id) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1; > > > > models > >class Model extends AppModel { > > var $name = 'Model'; > var $useTable = 'models'; > var $displayField = 'title'; > var $belongsTo = array( > 'Manufacturer' => array('className' => 'Manufacturer', > 'foreignKey' > => 'manufacturer_id', > 'conditions' > => '', > 'fields' => > '', > 'order' => '' > ) > ); > > } > ?> > >class Manufacturer extends AppModel { > > var $name = 'Manufacturer'; > var $useTable = 'manufacturers'; > var $displayField = 'title'; > > var $hasMany = array( > 'Model' => array('className' => 'Model', > 'foreignKey' > => 'manufacturer_id', > 'order' => '' > ) > ); > > } > ?> > > controler: >{ > var $scaffold; > } > ?> > > > > -- -- (the old fart) the advice is free, the lack of crankiness will cost you - its a fine line between a real question and an idiot http://blog.samdevore.com/archives/2007/03/05/when-open-source-bugs-me/ http://blog.samdevore.com/cakephp-pages/my-cake-wont-bake/ http://blog.samdevore.com/cakephp-pages/i-cant-bake/ --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 final release date
> And looking at the bug list in trac, I wouldn't say there are any > major changes in the pipeline either. Going from 1.1 to 1.2 isn't > totally trivial, so the sooner you get started on such a transition > the better. If you are waiting for a "final" release before making > that change, I would re-think the strategy, and instead just go with > the current build. Well, I've been working with 1.2 beta since a while now. Since the very beginning in fact. Changes from 1.1 to 1.2 were so important that after 2 days learning 1.1, I switched to 1.2 even there was no "official" doc yet. New Cookbook is nice and a good way to start learning :D I've got a website working with 1.2 beta nicely and I'm currently working on a total recode of my good old (and rather badly coded) PHP4 webstore --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
version 1.2 scaffolding drop down.
Hello All, before I get yelled at I tried all the solutions I found on here before posting none of them worked. I have the following structure and I can't get scaffolding to generate a drop down of Manufacturers instead a get a text box. tables CREATE TABLE manufacturers ( id smallint(6) NOT NULL auto_increment, title varchar(50) NOT NULL, PRIMARY KEY (id), UNIQUE KEY `name` (title) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; CREATE TABLE models ( id smallint(6) NOT NULL auto_increment, manufacturer_id smallint(11) NOT NULL, model varchar(50) NOT NULL, voltage set('A/C','D/C') NOT NULL, kw varchar(20) NOT NULL, PRIMARY KEY (id), KEY manufacturer_id (manufacturer_id) ) ENGINE=MyISAM DEFAULT CHARSET=latin1; models array('className' => 'Manufacturer', 'foreignKey' => 'manufacturer_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); } ?> array('className' => 'Model', 'foreignKey' => 'manufacturer_id', 'order' => '' ) ); } ?> controler: --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Editing paginator URL
I don't know if this was something to do with my setup, but I had problems with setting the url options for pagination when using admin routing. my pagination links were coming out /admin/users/admin_index/ page:2/search:term I had to add an action parameter to the url options array to make it work: $paginator->options(array('url' => array('search'=>$search, 'action'=>'index'))); Just thought I'd post it in case someone else gets the same issue --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: order a find('list')?
omg that was so freaking obvious! I'd been trying all sorts of things; that never occurred to me. Thanks a bunch! On Fri, Apr 25, 2008 at 1:53 AM, squawk <[EMAIL PROTECTED]> wrote: > > Try this: > > find('list', array('order'=> 'field')); > > > > On Apr 24, 11:21 pm, "b logica" <[EMAIL PROTECTED]> wrote: > > cake_1.2.x.x_24.01.2008 > > > > I need to specify an order on a find('list') call and nothing I've > > tried is working :-( > > > > Is the new find() format documented anywhere? I can't even remember > > where I learned about it. Can 'list' be ordered? > > > > For the interested, here's the relevant hunk of model.php: > > > > case 'list' : > > if (empty($query['fields'])) { > > $query['fields'] = > array("{$this->alias}.{$this->primaryKey}", > > "{$this->alias}.{$this->displayField}"); > > $keyPath = "{n}.{$this->alias}.{$this->primaryKey}"; > > $valuePath = "{n}.{$this->alias}.{$this->displayField}"; > > $groupPath = null; > > } else { > > if (!is_array($query['fields'])) { > > $query['fields'] = > String::tokenize($query['fields']); > > } > > if (count($query['fields']) == 1) { > > $keyPath = > "{n}.{$this->alias}.{$this->primaryKey}"; > > $valuePath = '{n}.' . $query['fields'][0]; > > $groupPath = null; > > $query['fields'] = > array("{$this->alias}.{$this->primaryKey}", > > $query['fields'][0]); > > } elseif (count($query['fields']) == 3) { > > $keyPath = '{n}.' . $query['fields'][0]; > > $valuePath = '{n}.' . $query['fields'][1]; > > $groupPath = '{n}.' . $query['fields'][2]; > > } else { > > $keyPath = '{n}.' . $query['fields'][0]; > > $valuePath = '{n}.' . $query['fields'][1]; > > $groupPath = null; > > } > > } > > > > Believe me, I've tried! If it's impossible, I can always re-order the > > array when I get it. Or I could create a view in Postgres to keep any > > selects to this table ordered the way I want (it's a lookup table, > > basically, but order is important). But I'm curious is this can be > > done directly. > > > > --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 final release date
For the last few months I have been using the nightly build. It is pretty stable. If you follow the change log, it has been a while since any application breaking syntax changes have been introduced. And looking at the bug list in trac, I wouldn't say there are any major changes in the pipeline either. Going from 1.1 to 1.2 isn't totally trivial, so the sooner you get started on such a transition the better. If you are waiting for a "final" release before making that change, I would re-think the strategy, and instead just go with the current build. -Aran On Apr 25, 7:10 am, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote: > There is a hint in this article (at the very end) that it might be out > very soon.. > > http://bakery.cakephp.org/articles/view/after-3-years-looking-back-an... > > Let us pray.. :-) > > On Apr 25, 4:02 pm, seb <[EMAIL PROTECTED]> wrote: > > > Well, this might have been asked a few times before but does anybody > > have any idea when 1.2 will be available as stable release ? > > > Yes I know "When it's done" > > > :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Init ACL with CLI?
1) The syntax in the end is correct. You could also do: cake acl create aro root superadmin 2) When you create a node in the CLI, the model and foreign_key fields are blank. If you want these fields added automatically, then you need to add the nodes from within your application using the models you created. I presume you are using the AclBehavior? Anyways, be aware that the AclBehavior does NOT create the alias for you, so you will have to create some coding to handle the alias creation automatically. 3) I personally feel that it is easier to put the most generic user at the top of my ARO tree and put the superuser at the bottom. Let's say you have a user and an editor. If the editor is the parent of the user, you would have to do this: cake acl grant editor articles update cake acl grant editor articles read cake acl grant editor articles create cake acl deny user articles update cake acl deny user articles create If the user is the parent of the editor, then this is all you need: cake acl grant user read cake acl grant editor create cake acl grant editor update -Aran On Apr 25, 7:19 am, avairet <[EMAIL PROTECTED]> wrote: > Hi everybody, > > I'm trying to use the ACL, but I don't understand some stuff. > > I have created the 3 tables (aros, acos, aros_acos) with the CLI. > Fine. > I have a Groups table (called 'admin_groupes' in my case). > I have a Users table (called 'administrateurs' in my case), with a FK > called "admin_groupe_id" > > I want create 3 aros : SuperAdmin, Admin, Redacteur that correspond to > my AdminGroupes > > So, I want create my first aro with the CLI and the mystery start! > How must I launch my command in CLI? > > Because I've tested this : > > cake acl create aro AdminGroupe 1 null "Super Admin" > > and I've this error message : Could not find parent node using > reference "AdminGroupe" > > If I launch this other command: > > cake acl create aro / null "Super Admin" > > I obtain this message : New Aro 'null' created. > > And finally, if I launch : cake acl create aro / "Super Admin", that > works fine, but the "model" and "foreign_key" fields from my aros > table are empty... Why? Is it normal? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
thanks alot guys everything clear now :) On Apr 25, 4:08 pm, seb <[EMAIL PROTECTED]> wrote: > rtanz wrote: > > cheers that worked perfectly, another thing while we're at it, i am > > noticing that the code works the same whether you use single or double > > quotes, is one or the other better? Sorry might be a php thing and > > nothing related to cake, im not an expert in php itself either. thanks > > Using single or double quotes does not change anything. Both are string > delimiters. > > *BUT* if you use double quotes you'll be able to escape some more sequences. > > Have a look at : > > http://us2.php.net/manual/en/language.types.string.php#language.types... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Slow...
Thanks for all your advices. I actually did not use the Bindable behavior and the packing Scriptaculous. You are right NOSLOW about the Debug, I set it to 0 and it is better but still not the way I want. Anyway, thanks for the tips, I going to look at these right now ! NOSLOW a écrit : > I, too, use the Bindable behavior (couldn't live without it now ;). My > point was that Cake will still load all the related models recursively > for the controller action you're calling before you can dynamically > unbind the relationships. The only way I saw to prevent this was to > not define all the relationships in your model. I haven't gone into > production yet with my app so I haven't figured out what I'm going to > do about this. Optimization comes last (although it's slowing me down > a bit during development). > > > -- Pierre [EMAIL PROTECTED] _ CableOrganizer.com 5610 NW 12th Ave, suite 214 Ft.Lauderdale, FL 33309 Phone: 954-861-6310 --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Slow...
I, too, use the Bindable behavior (couldn't live without it now ;). My point was that Cake will still load all the related models recursively for the controller action you're calling before you can dynamically unbind the relationships. The only way I saw to prevent this was to not define all the relationships in your model. I haven't gone into production yet with my app so I haven't figured out what I'm going to do about this. Optimization comes last (although it's slowing me down a bit during development). --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
View this page "CakePHP In The Wild"
-Restored missing link http://viewvc.svn.mozilla.org/vc/addons/branches/ Click on http://groups.google.com/group/cake-php/web/cakephp-in-the-wild - or copy & paste it into your browser's address bar if that doesn't work. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Slow...
Hello everybody, I, too, use Firefox and Firebug. Firebug running really slows down the loading/initialization speed of any page that uses a lot of javascript. Additionally the Script.aculo.us libraries a rather big. A suggestion would be to google for packed versions of Script.aculo.us and Prototype and include these instead. This sizes differ significantly - so at least download speed will most likely increase. But these are just client side improvements. I experience really good performance improvements with un/binding Models at need just like NOSLOW suggested. What really works well is the Bindable behavior which I use for all my models. I recommend to a look at this bakery article: http://bakery.cakephp.org/articles/view/bindable-behavior-control-your-model-bindings jost On Apr 25, 3:48 pm, NOSLOW <[EMAIL PROTECTED]> wrote: > I've had some issues too and will share some of my findings in hopes > some more knowledgeable people will correct me where I'm wrong: > > Is debug level set to 0? If there are lots of models loading (and not > being cached) you'll hit some overhead. > > Probably not related to your specific problem, but I've noticed if you > have a bunch of models loading with your request, there's 100-200ms of > overhead per each model load. I've hit this problem with 20-30 models > loading foreach of my ajax requests. If you look in your app\tmp\cache > \models directory, you'll see these model cache files being recreated > during each request. > > After spending days tracking this down, I figured that I'll just > unbind all the models and bind just the needed ones. Uh-uh. Cake does > all this *before* you get a chance at it (the best I could tell is > that your first chance at anything is in Controller::beforeFilter(), > which happens after all the model classes are contsructed). > > My conclusion (someone please correct me if I'm wrong here): if you > have many relationships and don't use caching of your models, you'll > have to avoid defining default bindings in your model files and > manually bind models as needed per request. > > Another thing to note when debug level is not set to 0, your > javascript files will be forced down with every page load. This is not > an issue with ajax requests, though. Packaging/minifying your script > and css is a good strategy to adopt to improve performance in that > regards. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Init ACL with CLI?
Hi everybody, I'm trying to use the ACL, but I don't understand some stuff. I have created the 3 tables (aros, acos, aros_acos) with the CLI. Fine. I have a Groups table (called 'admin_groupes' in my case). I have a Users table (called 'administrateurs' in my case), with a FK called "admin_groupe_id" I want create 3 aros : SuperAdmin, Admin, Redacteur that correspond to my AdminGroupes So, I want create my first aro with the CLI and the mystery start! How must I launch my command in CLI? Because I've tested this : cake acl create aro AdminGroupe 1 null "Super Admin" and I've this error message : Could not find parent node using reference "AdminGroupe" If I launch this other command: cake acl create aro / null "Super Admin" I obtain this message : New Aro 'null' created. And finally, if I launch : cake acl create aro / "Super Admin", that works fine, but the "model" and "foreign_key" fields from my aros table are empty... Why? Is it normal? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
HasMany HTML Selects in Baked Views
This is a simple thing but I don't think it's currently supported... Running 'cake bake view' (or 'cake bake all' in my specific case) creates add and edit view files with lines such as: echo $form->input('contact_id'); When the value (e.g. 'contact_id') is a foreign key for an another object in a HasMany relationship with the object being added or edited, a html select form element is created (HABTM relationships always get 'select multiple' elements which always allow selecting none of the options). Unfortunately with these select elements one of the options is always selected, which can be rather annoying, particularly when I am just starting to populate a database. That being said, I can see (and have) many normal use cases where I'd like to have the value be NULL. So, it'd be great if there was always a blank (ie NULL) option added to the select options. If I update the actual database tables and set the relevant row to NULL, Cake handles it just fine. Looking at the manual, the $option['empty'] for $form->input() looks like it does the trick: http://book.cakephp.org/view/201/options-empty. So, do people think it would be unreasonable to make this part of the default functionality of $form->input() for HTML form selects? Or at least have cake bake output something like this: $form- >input('contact_id', , 'empty' => __('None')))? What do you think? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Cake 1.2 final release date
There is a hint in this article (at the very end) that it might be out very soon.. http://bakery.cakephp.org/articles/view/after-3-years-looking-back-and-moving-ahead Let us pray.. :-) On Apr 25, 4:02 pm, seb <[EMAIL PROTECTED]> wrote: > Well, this might have been asked a few times before but does anybody > have any idea when 1.2 will be available as stable release ? > > Yes I know "When it's done" > > :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
rtanz wrote: > cheers that worked perfectly, another thing while we're at it, i am > noticing that the code works the same whether you use single or double > quotes, is one or the other better? Sorry might be a php thing and > nothing related to cake, im not an expert in php itself either. thanks Using single or double quotes does not change anything. Both are string delimiters. *BUT* if you use double quotes you'll be able to escape some more sequences. Have a look at : http://us2.php.net/manual/en/language.types.string.php#language.types.string.syntax.single --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
Well, if you put double quotes, you then can put variables inside a string and they will be replaced by proper values. Single quoted strings are not parsed. I tend to use single quotes because it is supposedly a bit faster to process by the PHP parser. You can read more about these here: http://www.trans4mind.com/personal_development/phpTutorial/quotes.htm http://spindrop.us/2007/03/03/php-double-versus-single-quotes/ Welcome to the PHP world! ;-) On Apr 25, 3:58 pm, rtanz <[EMAIL PROTECTED]> wrote: > cheers that worked perfectly, another thing while we're at it, i am > noticing that the code works the same whether you use single or double > quotes, is one or the other better? Sorry might be a php thing and > nothing related to cake, im not an expert in php itself either. thanks > > On Apr 25, 3:52 pm, seb <[EMAIL PROTECTED]> wrote: > > > rtanz wrote: > > > tried that and got this error > > > > Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ > > > public_html/survey/app/views/surveys/edit.ctp on line 9 > > > Sorry for that, I should have done a cut & paste from my own code. Made > > a typo by forgetting to enclose all things related to select field > > inside an array. Hey, this is Friday, I'm a bit tired ! :D > > > Here is the right syntax : > > > echo > > $form->input("my_field_name",array("type"=>"select","options"=>array("0"=>"NO","1"=>"YES"),"selected"=>"1")); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Cake 1.2 final release date
Well, this might have been asked a few times before but does anybody have any idea when 1.2 will be available as stable release ? Yes I know "When it's done" :D --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Can Cake Do Calculated Ordered List SQL Queries?
Mark Lawton wrote: > Hi Everyone, > > I would like to switch to using Cake, but looking at > http://manual.cakephp.org/view/66/models , I don't see an obvious way > to ask for a calculated ordered list from a database - and these are > indispensable to our website. Suppose, for example, one wanted the 10 > healthiest cakes: the SQL query might look like this: > > select price, name, 2 * protein + log(fibre) - 10 * salt - sugar - fat > as health order by health limit 10 > > Can somebody tell me how we would be able to do such lists in Cake, > please? Well, if I understand well what you want to do, this is just as basic as doing a Model->query or a Model->find(All) As a result you get a set of data ordered the way you asked for it inside your query. Browse thru them with a simple foreach loop. Did I missed something ? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
cheers that worked perfectly, another thing while we're at it, i am noticing that the code works the same whether you use single or double quotes, is one or the other better? Sorry might be a php thing and nothing related to cake, im not an expert in php itself either. thanks On Apr 25, 3:52 pm, seb <[EMAIL PROTECTED]> wrote: > rtanz wrote: > > tried that and got this error > > > Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ > > public_html/survey/app/views/surveys/edit.ctp on line 9 > > Sorry for that, I should have done a cut & paste from my own code. Made > a typo by forgetting to enclose all things related to select field > inside an array. Hey, this is Friday, I'm a bit tired ! :D > > Here is the right syntax : > > echo > $form->input("my_field_name",array("type"=>"select","options"=>array("0"=>"NO","1"=>"YES"),"selected"=>"1")); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Can Cake Do Calculated Ordered List SQL Queries?
Using any type of sql function is easy in cake. Your example would be as simple as: $data = $this->Cake->find('all', array( 'fields' => array('price', 'name', '(2*protein+LOG(fibre)-10*salt- sugar-fat) AS health'), 'order' => 'health', 'limit' => 10 )); The one 'gotcha' is that the result won't be where you might expect in the returned data. Calculated fields have no associated table, so as far as cake can see; they belong to no model. So your returned data array would look like this: [0] => array( 'Cake' => array('price' => 123, 'name' => 'Grigri\'s homemade lemon curd cheesecake'), [0] => array('health' => 1.8e-308) ), [1] => array( 'Cake' => ... [0] => ... ), Note that the calculated field "health" is indexed under [0], not 'Cake' or some other joined model. There are a number of behaviors floating around to sort this out, but it's usually easier just to work with the data in-place. If you have a second calculated field it will be indexed under [0] too. Note that you can cheat on some databases (postgres for example) by doing '(...) AS Model__field' (double-underscore), and it will get indexed with the model. Not sure if this a good idea though. hth grigri On Apr 25, 2:26 pm, Mark Lawton <[EMAIL PROTECTED]> wrote: > Hi Everyone, > > I would like to switch to using Cake, but looking > athttp://manual.cakephp.org/view/66/models, I don't see an obvious way > to ask for a calculated ordered list from a database - and these are > indispensable to our website. Suppose, for example, one wanted the 10 > healthiest cakes: the SQL query might look like this: > > select price, name, 2 * protein + log(fibre) - 10 * salt - sugar - fat > as health order by health limit 10 > > Can somebody tell me how we would be able to do such lists in Cake, > please? > > btw - although the above SQL query is obviously contrived, we really > do use mathematical functions like log() in making our ordered lists. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
Have you tried this: echo $form->select('active', array('1' => 'Yes', '2' => 'No'), '1', array(), false); This should work for 1.2 On Apr 25, 11:28 am, rtanz <[EMAIL PROTECTED]> wrote: > hi i would like to make a select box with a label and dropdown, > default value 'Yes' and no empty value. I am trying this code but its > not working as i want to, can you help me out? > > echo $form- > > >select('active',array('0'=>'Yes','1'=>'No','Yes',null,false)); > > shown here: > > http://jpgalea.com/survey/surveys/add > > thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
rtanz wrote: > tried that and got this error > > Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ > public_html/survey/app/views/surveys/edit.ctp on line 9 Sorry for that, I should have done a cut & paste from my own code. Made a typo by forgetting to enclose all things related to select field inside an array. Hey, this is Friday, I'm a bit tired ! :D Here is the right syntax : echo $form->input("my_field_name",array("type"=>"select","options"=>array("0"=>"NO","1"=>"YES"),"selected"=>"1")); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Can Cake Do Calculated Ordered List SQL Queries?
On Fri, Apr 25, 2008 at 9:26 AM, Mark Lawton <[EMAIL PROTECTED]> wrote: > > select price, name, 2 * protein + log(fibre) - 10 * salt - sugar - fat > as health order by health limit 10 > > Can somebody tell me how we would be able to do such lists in Cake, > please? Try this, but I must warn you I have not tested it. $fields = array('price', 'name', '2 * protein + log(fibre) - 10 * salt - sugar - fat as health'); $order = array('health' => 'desc'); $limit = 10; $this->Foo->find('all', compact('fields', 'order', 'limit')); Hope that helps. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: how to save a particular field in php cake
Cookbook, API, Google, etc, etc, etc Cheers, mbavio mbavio.com.ar On Apr 25, 10:17 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote: > On Fri, Apr 25, 2008 at 5:41 AM, Rocky <[EMAIL PROTECTED]> wrote: > > > Plz help me out > > > How to save a particular field in php cake > > Before you ask your next question, I suggest you check > outhttp://book.cakephp.org, since so far your questions reveal that you > haven't done any research before asking. > > -- > Chris Hartjes > Internet Loudmouth > Motto for 2008: "Moving from herding elephants to handling snakes..." > @TheKeyBoard:http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Slow...
I've had some issues too and will share some of my findings in hopes some more knowledgeable people will correct me where I'm wrong: Is debug level set to 0? If there are lots of models loading (and not being cached) you'll hit some overhead. Probably not related to your specific problem, but I've noticed if you have a bunch of models loading with your request, there's 100-200ms of overhead per each model load. I've hit this problem with 20-30 models loading foreach of my ajax requests. If you look in your app\tmp\cache \models directory, you'll see these model cache files being recreated during each request. After spending days tracking this down, I figured that I'll just unbind all the models and bind just the needed ones. Uh-uh. Cake does all this *before* you get a chance at it (the best I could tell is that your first chance at anything is in Controller::beforeFilter(), which happens after all the model classes are contsructed). My conclusion (someone please correct me if I'm wrong here): if you have many relationships and don't use caching of your models, you'll have to avoid defining default bindings in your model files and manually bind models as needed per request. Another thing to note when debug level is not set to 0, your javascript files will be forced down with every page load. This is not an issue with ajax requests, though. Packaging/minifying your script and css is a good strategy to adopt to improve performance in that regards. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Session need HELP
On Fri, Apr 25, 2008 at 8:51 AM, KND <[EMAIL PROTECTED]> wrote: > > If i can set the session in controller.. > In that session is destroy i am click another controller.. > > I need to maintain the session for all the controller.. > > > Please help me how to maintain the session values.. > http://book.cakephp.org -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Problem in using Ajax to submit a form
Hi, Maybe try submiting not by ajax->form but ajax->submit eg echo $form->create('Sphere'); ... echo $ajax->submit('save', array('url'=>'saveSpheres','update'=>'sphere_val', 'before' => 'prepareSpheres()')); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Can Cake Do Calculated Ordered List SQL Queries?
Hi Everyone, I would like to switch to using Cake, but looking at http://manual.cakephp.org/view/66/models , I don't see an obvious way to ask for a calculated ordered list from a database - and these are indispensable to our website. Suppose, for example, one wanted the 10 healthiest cakes: the SQL query might look like this: select price, name, 2 * protein + log(fibre) - 10 * salt - sugar - fat as health order by health limit 10 Can somebody tell me how we would be able to do such lists in Cake, please? btw - although the above SQL query is obviously contrived, we really do use mathematical functions like log() in making our ordered lists. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Session need HELP
If i can set the session in controller.. In that session is destroy i am click another controller.. I need to maintain the session for all the controller.. Please help me how to maintain the session values.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: reset Session variables without any visible cause
On Sun, Mar 16, 2008 at 8:58 AM, jano <[EMAIL PROTECTED]> wrote: > > I'm sorry to bother you with this strange problem, but I don't know > really how manage it. > Permorfing some action in my cake application, variables session are > 'sometimes' resetted. It happens not so often, and in a unpredictable > way: i.e. the same manipulation, repeated again, does not have this > 'reset'. Here's a crazy thought: you are doing something wrong in your code. I have found in my vast experience with CakePHP that sessions don't magically disappear, but they disappear for a variety of well-known reasons. Some of which you might be able to find by searching this Google group. If you are using CakePHP 1.2, I suggest you check in config/core.php and see what you've set Session.checkAgent to be. If you are doing anything with Ajax, you usually need to set this to 'false' or else it causes a new session to be created, thus dumping all your old session information. I suggest pasting some of your code into bin.cakephp.org so others can see what you're doing. When doing anything in Cake, I believe there is a really good rule to follow: Don't assume it's a bug in Cake if your code won't work properly. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: how to save a particular field in php cake
On Fri, Apr 25, 2008 at 5:41 AM, Rocky <[EMAIL PROTECTED]> wrote: > > Plz help me out > > How to save a particular field in php cake > Before you ask your next question, I suggest you check out http://book.cakephp.org, since so far your questions reveal that you haven't done any research before asking. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Problem with widget in opera.
On Fri, Apr 25, 2008 at 2:24 AM, lekshmi <[EMAIL PROTECTED]> wrote: > > > Please help... > Does this look like a "Solving problems with Javascript in Opera" mailing list? If the javascript is being generated by Cake, then people will answer. If it isn't, then I believe that the problem exists between the keyboard and the chair. -- Chris Hartjes Internet Loudmouth Motto for 2008: "Moving from herding elephants to handling snakes..." @TheKeyBoard: http://www.littlehart.net/atthekeyboard --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: how to save a particular field in php cake
what he said but set your ID first $this->Model->id = 34; $this->Model->saveField('field_name', $field_value); On Apr 25, 5:41 am, Rocky <[EMAIL PROTECTED]> wrote: > Plz help me out > > How to save a particular field in php cake > > Thanks > Rocky --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: how to save a particular field in php cake
Dude $this->YourModel->saveField($field, $value) On Apr 25, 7:41 pm, Rocky <[EMAIL PROTECTED]> wrote: > Plz help me out > > How to save a particular field in php cake > > Thanks > Rocky --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Validation of related models in cake 1.2
Hi James. Yes I'm sure about the naming, but I didn't thought in explictilly call validates for the related model. Where I do that? In beforeSave of the related model, calling: this->validate(); Thanks very much for help. On 23 abr, 14:25, James K <[EMAIL PROTECTED]> wrote: > I haven't had this problem in 1.2 - even models which are nested > several levels all get picked up by the form helper. Are you sure > you're naming your form elements using the correct dot notation? > Model.RelatedModel.FieldName > > You also have to either explicitly call validates() on each model, or > have your save operations validate. Just validating the parent model > doesn't fire validation on the related models. > > On Apr 23, 4:36 am,ygneo<[EMAIL PROTECTED]> wrote: > > > Hi everybody! > > > I've reading the posts about validation of related models. > > I.E.;http://groups.google.com/group/cake-php/browse_thread/thread/856cda8e... > > > I've the same problem: validation errors of related model doesn't goes > > to the view and Form::error doesn't shows. > > > I've seen in the Trac that have been fixed in 1.1., so, what's the > > problem? I need to use the patch in Controller:render showed in the > > post above??? > > > Thanks a lot! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
how to save a particular field in php cake
Plz help me out How to save a particular field in php cake Thanks Rocky --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Session
If i can set the session in controller.. In that session is destroy i am click another controller.. I need to maintain the session for all the controller.. Please help me how to maintain the session values.. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: HABTM and conditions ?
Thank for your link ! I think it will be helpful for my issue :) Cordially, Neveldo - http://www.neveldo.fr --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
yes amit i used that syntax originally, but now i want to add those other options, i.e. I want Yes to be selected by default and I also dont want any blank fields. This is what I would like to achieve, so i need to add some more parameters... On Apr 25, 1:07 pm, "Amit Badkas" <[EMAIL PROTECTED]> wrote: > - You should use syntax like echo $form->select('active', array(0 => 'Yes', > 1 => 'No')); > > > > > > On Fri, Apr 25, 2008 at 3:56 PM, rtanz <[EMAIL PROTECTED]> wrote: > > > tried that and got this error > > > Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ > > public_html/survey/app/views/surveys/edit.ctp on line 9 > > > On Apr 25, 12:08 pm, seb <[EMAIL PROTECTED]> wrote: > > > rtanz wrote: > > > > hi i would like to make a select box with a label and dropdown, > > > > default value 'Yes' and no empty value. I am trying this code but its > > > > not working as i want to, can you help me out? > > > > With Cake 1.2, you should try this : > > > > echo > > > $form->input("type"=>"select","options"=>array("0"=>"No","1"=>"Yes"),"selected"=>"1")); > > -- > Regards, > Amit > > http://amitrb.wordpress.com/http://coppermine-gallery.net/http://cheesecake-photoblog.org/http://www.sanisoft.com/blog/author/amitbadkas- > Hide quoted text - > > - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
- You should use syntax like echo $form->select('active', array(0 => 'Yes', 1 => 'No')); On Fri, Apr 25, 2008 at 3:56 PM, rtanz <[EMAIL PROTECTED]> wrote: > > tried that and got this error > > Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ > public_html/survey/app/views/surveys/edit.ctp on line 9 > > On Apr 25, 12:08 pm, seb <[EMAIL PROTECTED]> wrote: > > rtanz wrote: > > > hi i would like to make a select box with a label and dropdown, > > > default value 'Yes' and no empty value. I am trying this code but its > > > not working as i want to, can you help me out? > > > > With Cake 1.2, you should try this : > > > > echo > > > $form->input("type"=>"select","options"=>array("0"=>"No","1"=>"Yes"),"selected"=>"1")); > > > -- Regards, Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Elementary Data Validation??
Well, I can see a few problems straight away: * You're confusing the 'required' and 'allowEmpty' validation keys. 'required' means it must be present in the array, 'allowEmpty' controls whether empty values are allowed. 'allowEmpty' is checked before anything else, so an empty field without `'allowEmpty' => false` won't even make it to your validation routine. * Your regular expressions are erroneous: (In your first post) 'rule' => array('custom', '/[A-Z]{2}$/i'), You've specified in the comments 'Must exist and be two capital letters, eg CA', whereas your regexp says 'must end with 2 letters'. A more correct one would be '/^[A-Z]{2}$/' * the 'comparaison' validation isn't type-specific. So your `array('comparison', '>=', 1)` doesn't mean "must be a number not less than one", it means "must not come after 1 when sorted alphabetically". Try using a regular expression like '/^[1-9][0-9]* $/' (which means first character must be 1..9, all the others must be 0..9). Also, your form generation code looks incredibly verbose. You might want to look into the FormHelper::inputs() method. I get a complicated form layout with this code: 'Account Login Details', 'defaults' => array('before' => '', 'between' => '', 'after' => ''), 'Customer.email'=> array('size' => 30), 'Customer.password' => array('size' => 30), 'Customer.confirm_email'=> array('size' => 30), 'Customer.confirm_password' => array('size' => 30, 'type' => 'password'), ); echo $form->inputs($fields); ?> 'Your Details', 'defaults' => array('before' => '', 'between' => '', 'after' => ''), 'Customer.firstname'=> array('size' => 30), 'Customer.surname' => array('size' => 30), 'Customer.tos' => array('div'=>true, 'type'=>'checkbox', 'class' => 'checkbox', 'label' => 'I agree to the ' . $html->link('Terms of Service', '/pages/terms', array('target' => '_blank'))) ); echo $form->inputs($fields); ?> submit('submit-button.png', array('alt' => 'Submit')); ?> (Note that the confirm_email, confirm_password and tos do not correspond to fields in the schema, but they do have validation entries). Anyway, hope this helps grigri On Apr 24, 10:12 pm, Jee <[EMAIL PROTECTED]> wrote: > Why won't the validation messages for 'state' and 'agreed_to_terms' > show up on the form below when an error is made? > The validations and the action are below the form code. > > I could have written this stupid thing ten times over in the time I > have been fighting with cakephp over this. > > Thanks for any help! > Jee > > The Form: > === > echo "Agency Details"; > echo "Items marked like this are required."; > > echo $form->label('name', 'Name', array('class' => 'required')); > echo $form->input('name', array('tabindex' => $tabvar++, 'label' => > false, 'div' => false)); > > echo $form->label('address', 'Address', array('class' => > 'required')); > echo $form->input('address', array('tabindex' => $tabvar++, 'label' > => false, 'div' => false)); > > echo $form->label('address_continued', 'Address Continued', null); > echo $form->input('address_continued', array('tabindex' => $tabvar+ > +, 'label' => false, 'div' => false)); > > echo $form->label('city', 'City', array('class' => 'required')); > echo $form->input('city', array('tabindex' => $tabvar++, 'label' => > false, 'div' => false)); > > echo $form->label('state', 'State', array('class' => 'required')); > echo $form->select('state', array('options' => > $geography->stateList(), 'tabindex' => $tabvar++, 'label' => false, 'div' => > > false)); > > echo $form->label('county', 'County', array('class' => > 'required')); > echo $form->input('county', array('tabindex' => $tabvar++, 'label' > => false, 'div' => false)); > > echo $form->label('zip', 'Zip', array('class' => 'required')); > echo $form->input('zip', array('tabindex' => $tabvar++, 'label' => > false, 'div' => false)); > > echo $form->label('phone', 'Phone', array('class' => 'required')); > echo $form->input('phone', array('tabindex' => $tabvar++, 'label' > => false, 'div' => false)); > > echo $form->label('secondary_phone', 'Secondary Phone', null); > echo $form->input('secondary_phone', array('tabindex' => $tabvar++, > 'label' => false, 'div' => false)); > > echo $form->label('fax', 'Fax', null); > echo $form->input('fax', array('tabindex' => $tabvar++, 'label' => > false, 'div' => false)); > > echo $form->label('federal_taxid', 'Federal Tax ID', array('class' > => 'required')); > echo $form->input('federal_taxid', array('tabindex' => $tabvar++, > 'label' => false, 'div' => false)); > > echo "Primary Contact Details legend>"; > > echo $form->label('contact_name', 'Name', array('class' => > 'required', 'for' => 'MemberCont
Re: Form data not available in controller
- Please debug the $this->params['form'] and $this->data in your controller's action and take a look at it if something is not working properly On Thu, Apr 24, 2008 at 9:49 PM, zendrumz <[EMAIL PROTECTED]> wrote: > > Hey everyone, > > I'm a cakephp newbie putting together my first project. I'm trying to > save form data to my database through a form generated by the > formHelper in a view element. The problem I'm having is that $this- > >data is apparently empty when I try to access it from my controller. > I've checked my HTTP headers, and my form data is indeed being POSTed. > I've followed all of cakephp's naming conventions and the framework > does have proper access to the database. When I submit the form, the > controller branches to display the error message in my view, along > with the following: > > 1 query took 2 ms > Nr Query Error AffectedNum. rows Took (ms) > 1 DESCRIBE `contacts` 6 6 2 > > > Here's the relevant code: > > Model: > > class Contact extends AppModel > { >var $name = 'Contact'; > } > > Controller: > > class ContactsController extends AppController{ >var $name = 'Contacts'; >var $helpers = array('Html','Javascript','Form'); >function add(){ >if (!empty($this->data)){ >if($this->Contact->create($this->data) && > $this->Contact->save()) > { >$this->flash('Your information has been > saved.','/'); >} >} >else{ >$this->flash('An error has ocurred. Please contact us > directly at: > info (at) shrineaudio (dot) com.','/'); >} >} > } > > Form: > > > contact us > echo $form->create('Contact'); >echo $form->input('name', array('label' => '*Name:')); >echo $form->input('email', array('label' => > '*Email:')); >echo $form->input('phone', array('label' => 'Phone:')); >echo $form->input('message', array('type' => 'textinput','label' => > '*Tell us about your project: span>','div'=>'leftalign')); >echo $form->submit('submitbutton.gif'); >echo $form->end(); > ?> > > > Any help would be greatly appreciated. As you can see, I essentially > copied the code for my model and controller from the blog tutorial, so > I'm at a loss as to explain why it isn't working. Thanks a lot! > > > > -- Regards, Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
tried that and got this error Parse error: syntax error, unexpected T_DOUBLE_ARROW in /home/jpgalea/ public_html/survey/app/views/surveys/edit.ctp on line 9 On Apr 25, 12:08 pm, seb <[EMAIL PROTECTED]> wrote: > rtanz wrote: > > hi i would like to make a select box with a label and dropdown, > > default value 'Yes' and no empty value. I am trying this code but its > > not working as i want to, can you help me out? > > With Cake 1.2, you should try this : > > echo > $form->input("type"=>"select","options"=>array("0"=>"No","1"=>"Yes"),"selected"=>"1")); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
On Fri, Apr 25, 2008 at 2:58 PM, rtanz <[EMAIL PROTECTED]> wrote: > > hi i would like to make a select box with a label and dropdown, > default value 'Yes' and no empty value. I am trying this code but its > not working as i want to, can you help me out? > >echo $form- > >select('active',array('0'=>'Yes','1'=>'No','Yes',null,false)); - You should use syntax like echo $form->select('active', array(0 => 'Yes', 1 => 'No', 0); > > > shown here: > > http://jpgalea.com/survey/surveys/add > > > thanks > > > -- Regards, Amit http://amitrb.wordpress.com/ http://coppermine-gallery.net/ http://cheesecake-photoblog.org/ http://www.sanisoft.com/blog/author/amitbadkas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: problem making a select box
rtanz wrote: > hi i would like to make a select box with a label and dropdown, > default value 'Yes' and no empty value. I am trying this code but its > not working as i want to, can you help me out? With Cake 1.2, you should try this : echo $form->input("type"=>"select","options"=>array("0"=>"No","1"=>"Yes"),"selected"=>"1")); --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Form data not available in controller
> Sorry, I just meant the error message I added in my controller (the > flash message in the else clause) i.e. cakephp doesn't think there's > anything in $this->data. In your controller, did you try this : $this->Model->create(); $this->Model->save($this->data); instead of : $this->Model->create($this->data); $this->Model->save(); Since you say that data are POSTed, $this->data is filled. Seems that something is wrong in the "save" part of your code. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: MySQL Views support in Cake 1.2
I know nothing about using MySQL views, but I've never found it a problem to filter/sort on deep associations. The trick is to use dynamic associations - a temporary `hasOne` instead of a `hasMany`, so that cakephp performs a join and you can then filter inline in the query. For example, let's assume that : Post hasOne Author [class: User] User hasOne Profile Post hasAndBelongsToMany Tag [with: PostsTag] And you want to find all posts written by a user with a [EMAIL PROTECTED] email [in Profile] which is associated to either 'Bacon' or 'Eggs' tags. You also want to order the results first by whether the Tag is Bacon or Eggs, then by the Author's surname [I'll do this manually here -- so you can see what's going on; there are a lot of behaviors and extra code around to make it easier and less verbose] First, set up the dynamic bindings: $this->Post->bindModel(array( 'hasOne' => array( 'AuthorProfile' => array('className' => 'Profile', 'foreignKey' => false, 'conditions' => 'AuthorProfile.author_id=Author.id'), 'PostsTag1' => array('className' => 'PostsTag', 'foreignKey' => false, 'conditions' => 'PostsTag1.post_id=Post.id'), 'Tag1' => array('className' => 'Tag', 'foreignKey' => false, 'conditions' => 'PostsTag1.tag_id=Tag.id'), ) ), false); Now call findAll() with the conditions based on your previous keys: $data = $this->Post->find('all', array( 'fields' => 'Post.*, Author.*', 'recursive' => 0, // This can be higher to fetch associated stuff, of course [but not lower!] 'conditions' => array('AuthorProfile.email' => 'LIKE [EMAIL PROTECTED]', 'Tag1.tag' => array('Bacon', 'Eggs'), '1=1 GROUP BY Post.id'), 'order' => array('(Tag1.tag = \'Bacon\') DESC', 'Author.surname ASC') )); And there ya go! A few gotchas: * You must either use the GROUP BY or a DISTINCT rowset to avoid getting duplicate rows (e.g. if a Post was associated both with Bacon and Eggs) * If you're using paginate then don't forget the `false` parameter to bindModel() or you'll be in trouble * It's best to alias the dynamic joins distinctly from other associations - hence the 'Tag1'. * When performing multiple joins in a single query, make sure your database tables are indexed properly. Use EXPLAIN SELECT with wild abandon to get it fast and furious. This is proof-of-concept only; in practice it's usually more efficient to perform multiple queries than one giant one. Experiment away... Anyway, hope this helps - and not too off-topic. Someone else can help you out with using views, I'm sure. On Apr 24, 6:49 pm, Sebastian Veggiani <[EMAIL PROTECTED]> wrote: > Hi, > > somebody could clarify what is the level of support of Cake 1.2 for > woriking with MySQL Views? > > For example, I've a chain o associations of three or more levels. > > If I want to filter the results by a field in the 3rd level or beyond > there is no easy way to do it, unless I use a Custom SQL Query, but in > this case I can't use the Model paginator in the view. > > The solution I found was to create a View in MySQL with the necessary > data from joined tables and then filter by one of these fields. This > works OK for me. > > The problem comes with pagination and sorting. When I try to sort by > a view field which is not in the main table (specified by FROM) the > application fails. Ordering by any field in the main table works OK. > > anybody knows something about MySQL Views in cake? > > Thanks, --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Adding new records into two models with one form (or: trying to validate without saving)
> First, set the data to the model: > > $this->ModelName->set( $this->data ); > > $this->ModelName->set( $this->data ); > > Then, to check if the data validates, use the validates method of the > > model, which will return true if it validates and false if it doesn't: > > if ($this->ModelName->validates()) { > // it validated logic > } else { > // didn't validate logic > } > > If it validates, then save the data ... Thank you very much, that did the trick! It seems a bit confusing how $this->Model->validates($this->data) doesn't work, but $this->Model->set($this->data) and $this->Model- >validates() does, so thanks for clarifying. Just for posterity, now I'm doing this, and it works like a charm: if (!empty($this->data)) { // The user's submitting her new record $this->Model->set($this->data); if ($this->Model->validates()) { // The main record hypothetically would add just fine if ($this->Model->RelatedModel->save($this->data)) { // The related record added just fine // Actually add the main record $this->Model->save($this->data)); $this->Session->setFlash("{$this->data['Model']['name']} has been added."); $this->redirect("wherever"); exit(); } else { // The related record wouldn't save $this->Session->setFlash("Sorry, {$this->data['Model'] ['name']} couldn't be added."); } } else { // The main record wouldn't hypothetically save $this->Session->setFlash("Sorry, {$this->data['Model'] ['name']} couldn't be added."); } } Thanks for your help, and I hope that clarifies things a bit for anyone else trying to do the same thing! Zoe. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Routing to RSS feed
> my only idea would be creating an rss controller and then redirect to > main/index.rss > obviously that is not really pretty Well, that's an idea but it still sounds as a workaround. For the moment, I've created an empty rss folder at the server root and a .htaccess with a "redirect permanent" inside. Damn :D Anyway, thanxx to everybody for taking some time ;) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: Displaying in Input Field Value of Parent Element
Hi togehter, first i've to thank you. Both things works now very fine. But for the concatenation i've antoher question. In the Members view i can access the new variable "fullname" without any problems. But it's not getting passed down to the bill, so i can't reach it there. Do you have an idea? Thank you in advance! bye Tom On 25 Apr., 03:01, "b logica" <[EMAIL PROTECTED]> wrote: > > > In the Members table i've two columns "lastname" and "firstname". But > > > in the most cases i want to display the two names concatenated > > > ($lastname . ' ' . $firstname) for this i want to store the > > > concatenated string in a "pseudo" column "completename" (to acess it > > > with [member][completename]). How can i do this? > > > Well, I cannot understand why you want to do this... > > Probably or the same reason the other zillion or so of us want to. > This is really common. > > There are a few of ways you can approach this. The first is to do it > in your SELECT query but you might end up just fighting Cake on this. > > Another is to create an afterFind() method in your model and loop > through the array, attaching a new field to each with the concatenated > names. But you have to take into account that sometimes you'll have an > array with just one Member, other times, a list of all (or many) > Members. So your $data array will be structured differently: > > array( > ['Member'] > ['first_name'] => 'foo' > ['last_name'] => 'bar' > ... > ) > > vs. > > array( > [0] > ['Member'] > ['first_name'] => 'foo' > ['last_name'] => 'bar' > ... > [1] > ['Member'] > ['first_name'] => 'foo' > ['last_name'] => 'bar' > ... > ... > ) > > finally, you can forego all of that and use Yevgeny Tomenko's > AutoFieldBehavior:http://cakeexplorer.wordpress.com/category/model/ > > class Member extends AppModel > { > var $name = 'Member'; > > var $actsAs = array( > 'AutoField' => array( > 'full_name' => array( > 'fields' => array('first_name', 'last_name'), > 'mask' => '%s %s' > ) > ) > ); > ... > > } > > The behavior takes care of running through your data, figuring out > what structure you have. With this in place, you'll have a new field > with the concatenated name. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
problem making a select box
hi i would like to make a select box with a label and dropdown, default value 'Yes' and no empty value. I am trying this code but its not working as i want to, can you help me out? echo $form- >select('active',array('0'=>'Yes','1'=>'No','Yes',null,false)); shown here: http://jpgalea.com/survey/surveys/add thanks --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Custom View class in a Controller
Hello Can someone please tell me how to get the Controller::view property to work properly? I set the view to a custom view class in a controller (in the plugins folder). Whatever I tried, I didn't got Cake to load my view in a 'normal' expected way with any naming convention what so ever. What I have done now is in the beforeRender checking for this->view and loading the file manualy. Also, I tried loading with App::Import, but although it returned true, it didn't actually load the class, very strange. Wouldn't it be a nice idea to make it work just like loading models and controllers? In a plugin for example you can create a pluginname_app_controller class for instance, but somehow this doesn't seem to be the case with views. So how should it be done in a Cake way? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---
Re: reset Session variables without any visible cause
Checked with debug set to 0, unfortunately it didn't help. On Apr 24, 5:24 pm, cradick <[EMAIL PROTECTED]> wrote: > I don't have the problem anymore, but not exactly sure why it went > away. I seem to remember that the error was related to a stack > overflow due to the debug level set at 2 (probably search to find this > thread). This caused some custom code in my app_controller.php to fail > because the variables passed into it were lost. Then, for some reason > the error generated by app_controller reset the session variables. > Now, in app_controller I verify that a variable is set before trying > to use it and I see the correct error message. Hope that helps... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "CakePHP" 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?hl=en -~--~~~~--~~--~--~---