Re: Validate fields
you set the validation rules in the Model of whatever your using (i'm guessing users model) /app/models/user.php search for cakephp validation in google and look in the cakephp manual, it should be what you need. On Jan 5, 6:53 pm, kicaj wrote: > How validate field only we entered some value into input? > > For example: > I have form with fields: username, password and email > I set 'value'=>'' in edit template for password input field > When I edit this fields, I want update filed password only when I > wrote some new password, but when I lost empty field password, this > field will be not updated. This works, but: > How validate field when only wrote into? > > If field value is empty we not validate, but if field value is not > empty we get rules from $validate... > > How do this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Make objects from model data
When I was learning php classes we made a model object for each type of data we had. Each model would have crud from another class and then model specific functions & attributes. For example i would have: class Person extends Crud { var $first_name; var $last_name; static function getperson{ return Crud::get(people,$sql); } function full_name() { return $this->first_name . ' '. $this->last_name; } } class Crud { // crud static function get() { sql stuff; return mysql_rows} static function delete() {sql stuff; } } something like that, but anyways we would instantiate each item returned from the getallPeople() into a person object and then if i wanted to get the full name of the person i would just type: $person = Person::getperson(id); //creates person object $person->full_name(); // use object function this made it really easy because if i wanted to add something to the person all i had to do was change the Person object model. I cant get this to work with cakephp models. What do i need to do for this to work or do I not understand cakephp's models & MVC right? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Capture views output into a file?
Hi Nancy: Matt Curry wrote an HTML cacher helper that writes the entire view to a file and saves it in the webroot. Check out his helper code -- it seems to be doing exactly what you're after; writing the view to an HTML file. http://github.com/mcurry/html_cache http://github.com/mcurry/html_cache/blob/master/views/helpers/html_cache.php On Jan 4, 7:39 pm, Nancy wrote: > I'd like to be able to automatically generate a file from the output > of a view. Can anyone point me in the right direction? I don't see > any file i/o available to views, maybe I'm just missing it. > > Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Validate fields
How validate field only we entered some value into input? For example: I have form with fields: username, password and email I set 'value'=>'' in edit template for password input field When I edit this fields, I want update filed password only when I wrote some new password, but when I lost empty field password, this field will be not updated. This works, but: How validate field when only wrote into? If field value is empty we not validate, but if field value is not empty we get rules from $validate... How do this? Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Multimodel validate
Hi, I create form for example with two fields: Client.name, User.email. I send this form to Client model and validate 'name' field. But how I can validate field 'email'? Thanks! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
On Tue, Jan 5, 2010 at 5:59 PM, Fred Riley wrote: > (..) > I can't be the first person to have come across this issue. Is there > not a FAQ somewhere? Just include the directive RewriteBase /~theusername at the beginning of your .htaccess files. Best regards. -- MARCELO F ANDRADE Belem, Amazonia, Brazil "I took the red pill" Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
Sorry, Kees, I saw the second line in your reply but as you preceded it with "It might be that .htaccess files are not handled for user directories" I presumed that it didn't apply in my case, because .htaccess files plainly are handled in XAMPP. My mistake, and thanks for the second reply. Ok, looking at core.php the comments above 59 are quite plain, so I'll try the tweak tomorrow (I'm in beer time now, not work time :*)) and see what happens. I'd not realised that the only function of the .htaccess files was URL rewriting. I can't be the first person to have come across this issue. Is there not a FAQ somewhere? Cheers Fred On Jan 5, 7:50 pm, Kees de Bruin wrote: > Fred, > > As I wrote in my reply you have to make a small change in app/config/core.php > where you have to uncomment line 59 and remove the .htaccess files that are > listed just before that line. > > All URLs should now be something like ../cake/index.php/page instead of > ../cake/page Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: CakeFest IV - America - Help us pick a location!
San Jose!! it is silicon valley and I don't need to travel hahaha. San Francisco would work better probably though! :) On Jan 4, 9:47 am, drpark wrote: > Hi all! > Miami, Orlando, Wilmington NC, Las Vegas, Chicago, Seattle for the USA > in order of preference > Cancun for Mexico, > Vancouver for Canada > > But east coast is better for us (we are from France) > > On 4 jan, 09:21, Primeminister wrote: > > > New York! > > > On Nov 14 2009, 5:19 am, BrendonKoz wrote: > > > > Although I live east coast, I'd be more apt to go if it was some place > > > warm/tropical. Once you're in DC, it's not bad, but getting there if > > > you don't fly is a pain. Chicago's airport's pretty cool, but I've > > > never been outside of it. How is Texas's night life? Safe? > > > > Anyway, nice of the Cake team to ask! Thanks! > > > > On Nov 13, 11:02 pm, Miles J wrote: > > > > > Chicago seems cheap and cold, also one of the worse major cities in > > > > the US, why there? > > > > > I vote for New York, or Seattle, or Boston, or something. > > > > > On Nov 13, 7:36 pm, Renan Gonçalves wrote: > > > > > > Looks like Chicago is a nice place to host. > > > > > > On Fri, Nov 13, 2009 at 1:43 AM, Graham Weldon > > > > > wrote: > > > > > > > Hi all, > > > > > > > The CakePHP team has been considering the location for the next > > > > > > upcoming > > > > > > CakeFest. > > > > > > We've decided to bring it back home to the United Sates of America. > > > > > > Thus far we haven't chosen a location for the event, but to ensure > > > > > > we reach > > > > > > as many people as possible, we'd like your opinion on where we > > > > > > should host > > > > > > the event. > > > > > > > Essentially, our choices are: > > > > > > - USA East Coast > > > > > > - USA West Coast > > > > > > - USA Central > > > > > > > If I have missed another location that you feel might be more > > > > > > popular or > > > > > > accessible to interested attendees, feel free to suggest it. > > > > > > We're keen to hear peoples thoughts on it. > > > > > > > Cheers, > > > > > > > Graham Weldon (AKA: Predominant) > > > > > > > e. gra...@grahamweldon.com > > > > > > w.http://grahamweldon.com > > > > > > > -- > > > > > > You received this message because you are subscribed to the Google > > > > > > Groups > > > > > > "CakePHP" group. > > > > > > To post to this group, send email to cake-...@googlegroups.com. > > > > > > To unsubscribe from this group, send email to > > > > > > cake-php+unsubscr...@googlegroups.com > > > > > > . > > > > > > For more options, visit this group at > > > > > >http://groups.google.com/group/cake-php?hl=. > > > > > > -- > > > > > Renan Gonçalves aka renan.saddam > > > > > CakeDC Software Engineer > > > > > CakePHP Core Developer > > > > > Website: renangoncalves dot com > > > > > Extrema, MG, Brazil- Hide quoted text - > > > > > - Show quoted text - Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
weird unserialize issue in 1.3 alpha
Notice: unserialize() [function.unserialize]: Error at offset 6 of 1051 bytes in C:\xampp\htdocs\projects\courses\cake\libs\cache \file.php on line 189 anyone seen that before? I have 5 similar warnings all because the same line. I am on a windows machine running xampp. when i click notice the error reads: Code | Context $key= "cake_core_file_map" $time = 1262723833 $cachetime = 1262723843 $data = "a:6:{s:4:\"Core\";a:6:{s:6:\"Router\";s:53:\"C:\xampp\htdocs \projects\courses\cake\libs\router.php\";s:13:\"ClassRegistry\";s: 61:\"C:\xampp\htdocs\projects\courses\cake\libs\class_registry.php\";s: 12:\"Overloadable\";s:59:\"C:\xampp\htdocs\projects\courses\cake\libs \overloadable.php\";s:8:\"Security\";s:55:\"C:\xampp\htdocs\projects \courses\cake\libs\security.php\";s:4:\"l10n\";s:51:\"C:\xampp\htdocs \projects\courses\cake\libs\l10n.php\";s:4:\"i18n\";s:51:\"C:\xampp \htdocs\projects\courses\cake\libs\i18n.php\";}s:10:\"Controller\";a:4: {s:9:\"Component\";s:67:\"C:\xampp\htdocs\projects\courses\cake\libs \controller\component.php\";s:10:\"Controller\";s:68:\"C:\xampp\htdocs \projects\courses\cake\libs\controller\controller.php\";s: 13:\"AppController\";s:72:\"C:\xampp\htdocs\projects\courses\cake\libs \controller\app_controller.php\";s:15:\"PagesController\";s:74:\"C: \xampp\htdocs\projects\courses\cake\libs\controller \pages_controller.php\";}s:4:\"View\";a:2:{s:6:\"Helper\";s:58:\"C: \xampp\htdocs\projects\courses\cake\libs\view\helper.php\";s:4:\"View \";s:56:\"C:\xampp\htdocs\projects\courses\cake\libs\view\view.php\";} s:9:\"Component\";a:1:{s:16:\"SessionComponent\";s:76:\"C:\xampp\htdocs \projects\courses\cake\libs\controller\components\session.php\";}s: 6:\"Helper\";a:4:{s:9:\"AppHelper\";s:70:\"C:\xampp\htdocs\projects \courses\cake\libs\view\helpers\app_helper.php\";s:10:\"HtmlHelper\";s: 64:\"C:\xampp\htdocs\projects\courses\cake\libs\view\helpers\html.php \";s:10:\"FormHelper\";s:64:\"C:\xampp\htdocs\projects\courses\cake \libs\view\helpers\form.php\";s:13:\"SessionHelper\";s:67:\"C:\xampp \htdocs\projects\courses\cake\libs\view\helpers\session.php\";}s: 10:\"Datasource\";a:2:{s:9:\"DboSource\";s:75:\"C:\xampp\htdocs \projects\courses\cake\libs\model\datasources\dbo_source.php\";s: 8:\"DboMysql\";s:78:\"C:\xampp\htdocs\projects\courses\cake\libs\model \datasources\dbo\dbo_mysql.php\";}}" unserialize - [internal], line ?? FileEngine::read() - CORE\cake\libs\cache\file.php, line 189 Cache::read() - CORE\cake\libs\cache.php, line 306 App::getInstance() - CORE\cake\libs\configure.php, line 967 App::path() - CORE\cake\libs\configure.php, line 621 Configure::__loadBootstrap() - CORE\cake\libs\configure.php, line 416 Configure::getInstance() - CORE\cake\libs\configure.php, line 60 include - CORE\cake\bootstrap.php, line 38 [main] - APP\webroot\index.php, line 76 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
Fred, As I wrote in my reply you have to make a small change in app/config/core.php where you have to uncomment line 59 and remove the .htaccess files that are listed just before that line. All URLs should now be something like ../cake/index.php/page instead of ../cake/page Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
Thanks for the reply, Kees. On Jan 5, 4:23 pm, Kees de Bruin wrote: > Yes you can. Just put all inside your public_html directory (assuming that > user directories are enabled) or a subdirectory of public_html. Ok, that's useful to know. My immediate 'issue' is on localhost. I could, as Adeola suggested (thanks also for your reply), put Cake in htdocs as root user and I'm sure it would work fine, but as I'll not be able to do that on a live server I want to test Cake in a user account (http://localhost/~fredriley/). Now, if I unzip cake_1.2.5.zip into the user account's webroot on the Mac (Users/fredriley/Sites/ cake_1.2.5) that includes a .htaccess file with mod_rewrite directives, so that when I try the URL http://localhost/~fredriley/cake_1.2.5/ I get a 404. If I remove the .htaccess then the index.php script runs ok, but of course rewrites (as used in the tutorial cited) fail. I tried putting DocumentRoot /Users/fredriley/Sites/cake_1.2.5/app/webroot into the .htaccess but got an internal server error. So the follow-up question is: how do I configure Cake to run in a standard user account? Do I need to edit the .htaccess file, and if so what should I add? I've set permissions according to the fine manual, and have carried out the simple development installation. All of the installations, though, seem to assume root access to the system and Apache config - none mention standard user accounts. I'm very keen to use Cake. My client-side life has been vastly improved by the excellent jQuery (despite its steep learning curve), and if I can get a similar improvement on my server-side coding that could save me a lot of time and enable me to do far more with my web apps. Cheers Fred Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: MySQL takeover by Oracle - petition
Isn't it nice to have a descent data layer like we do in cake. Granted it might be a few days work to switch from MySQL to something like PostgreSQL for a decent sized project. But you probably have a few years before we ever get to that point where we are forced to do so. Don't sweat the small stuff enjoy the process of change and growth. I've seen a lot of changes since the 1980's in computer science where everyone reacted like it was the end of the world. Very few would go back to work in that environment leaving behind the tools and technology we have today. Things change, if they change for the worse thats too bad because those things occasionally die off. But I guarantee that those things that don't change and remain stagnant definitely die. I really don't think we should have any fear about what the future of MySQL holds for us. Its new changes that we all have an opportunity to still contribute to. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key).
I know this is a really "green" question, but how does the '{n}.State.id' section of your code work. I tried to look in my php manual but was at a loss of where to find information on this "data construct"/Placeholder/Whatever{n} is??? I have been at a loss as to how to navigate the "complex" arrays that cake sometimes give me since being new to programming/php/and cake. Thanks, David On Jan 4, 11:52 pm, bernalillo wrote: > $state_list = Set::combine($data, '{n}.State.id', '{n}.State.state'); Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
RE: Error Placement / Styles
Thanks John, Good looking out! I will add that since its more cake-ish than my current setup with the after method. Thanks again for your time and sorry for the confusion :) Dave -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of John Andersen Sent: January-05-10 2:45 PM To: CakePHP Subject: Re: Error Placement / Styles Hi Dave, I did understand that your hint was - a hint to the user - but I assumed that you would find out how to include that together with the form field definition :) Using the form helper, I would just add the "after" option to include something after the entry field. Using your hint code, I get the following HTML code. [code] E-mailRequired:Password must be minimum of 8 characters. [/code] As you can see, your hint is placed after the input tag. This is all done, just by using the form helper. My form helper code for the above is then: [code] print( $form->input( 'Reporter.email', array('label' => __ ('visitors_email',true), 'class' => 'email', 'error' => array ('report_email_rule' => __('report_email_rule',true) ), 'after' => 'Required:Password must be minimum of 8 characters.' ) ) ); [/code] If you don't want the error message to show up, just define it as " " - a blank ;) Well, if you can use it, good, else good that your solution is working also! Enjoy, John On Jan 5, 7:57 pm, "Dave" wrote: > Thanks, > > This works perfect. > error('User.password')){?> class='error'' > > > > After re-reading Johns email I think i gave the impression that the > hint was the error message. That is where I may have causeed some > confusion. The hint is always visible, its not an error message. > Imagine a field called "User.specialty" and the hint was "Please > describe briefly your background in this area". It only provides a hint to the user as to what info to enter. > Then if they skip that field I then display my error "Please enter > your Specialty"or what not > > Thanks guys, > > Dave > [snip] No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/05/10 04:05:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error Placement / Styles
CakePHP manual reference is http://book.cakephp.org/view/191/options-before-options-between-options-separator-a Enjoy, John Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error Placement / Styles
Hi Dave, I did understand that your hint was - a hint to the user - but I assumed that you would find out how to include that together with the form field definition :) Using the form helper, I would just add the "after" option to include something after the entry field. Using your hint code, I get the following HTML code. [code] E-mailRequired:Password must be minimum of 8 characters. [/code] As you can see, your hint is placed after the input tag. This is all done, just by using the form helper. My form helper code for the above is then: [code] print( $form->input( 'Reporter.email', array('label' => __ ('visitors_email',true), 'class' => 'email', 'error' => array ('report_email_rule' => __('report_email_rule',true) ), 'after' => 'Required:Password must be minimum of 8 characters.' ) ) ); [/code] If you don't want the error message to show up, just define it as " " - a blank ;) Well, if you can use it, good, else good that your solution is working also! Enjoy, John On Jan 5, 7:57 pm, "Dave" wrote: > Thanks, > > This works perfect. > error('User.password')){?> class='error'' > > > > After re-reading Johns email I think i gave the impression that the hint was > the error message. That is where I may have causeed some confusion. The hint > is always visible, its not an error message. Imagine a field called > "User.specialty" and the hint was "Please describe briefly your background > in this area". It only provides a hint to the user as to what info to enter. > Then if they skip that field I then display my error "Please enter your > Specialty"or what not > > Thanks guys, > > Dave > [snip] Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
RE: Error Placement / Styles
Thanks, This works perfect. error('User.password')){?> class='error'' > After re-reading Johns email I think i gave the impression that the hint was the error message. That is where I may have causeed some confusion. The hint is always visible, its not an error message. Imagine a field called "User.specialty" and the hint was "Please describe briefly your background in this area". It only provides a hint to the user as to what info to enter. Then if they skip that field I then display my error "Please enter your Specialty"or what not Thanks guys, Dave -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of Amit Rawat Sent: January-05-10 4:58 AM To: cake-php@googlegroups.com Subject: Re: Error Placement / Styles Try this, error('User.password')){?> class='error'' > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group cake-php+at http://groups.google.com/group/cake-php?hl=en No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 04:54:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
RE: Error Placement / Styles
Hello John, Only because I have my hint class in there so in my forms there is a little text beside each field. This is all wrapped inside the Sure I can get the input text error to get an error class to hi-light the text field, but looks rather dumb when the form has : Form [label] [field] [hint] [label] [field] [hint] [label] [field] [hint] [label] [field] [hint] Its not so much the error message I care about, I am not trying to place that anywhere, just the error class. I need to add it to the entire that houses my field, lable, and what not. So everything inside then has my red bg error class, not just the field and lable. -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of John Andersen Sent: January-05-10 5:16 AM To: CakePHP Subject: Re: Error Placement / Styles Well, now that I took a better look at your code, I don't understand why you don't use the standard cake form field and error generation, because that should be all you need :) Example HTML from my own code where the field has an error - it is mandatory: [code] print( $form->input( 'Reporter.email', array('label' => __ ('visitors_email',true), 'class' => 'email', 'error' => array ('report_email_rule' => __('report_email_rule',true) ) ) ) ); [/code] produces the following HTML when I don't enter an e-mail address! [code] E-mail reporter_email_rule [/code] Observe that the form helper has automatically inserted the error class in the div element! Enjoy, John On Jan 5, 10:15 am, "Dave" wrote: > Thanks John, > > I did set the 'error' => false so no message shows. But how do I get > the error class to end up inside the > > I tried an assortment of attemps with > > ??? > But nothing. > > Ideas? > > Thanks, > > Dave > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On > Behalf > > Of John Andersen > Sent: January-05-10 4:35 AM > To: CakePHP > Subject: Re: Error Placement / Styles > > Yes you can! > In the form field, add the option 'error' => false to disable the > automatic error message. Then use the form helpers error method for > the field and place it whereever you want. > Seehttp://book.cakephp.org/view/721/error > Enjoy, > John > > On Jan 5, 9:46 am, "Dave" wrote: > > Is it possible to determine where the error class gets added? > > > for example: > > > > > > > input('User.password', array('label' => > > 'Password:')); ?> > > Required: Password must be minimum of 8 > > characters. > > input('User.username', array('label' => > > 'Select a Username:')); ?> > > Required: Username can never be changed. > > > > > > > > So if a field fails i would like to add the error class to the > > so the entire row gets the error class like > > > Thanks > > > Dave > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help > others with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.com For more options, visit this > cake-php+group athttp://groups.google.com/group/cake-php?hl=en > No virus found in this incoming message. > Checked by AVG -www.avg.com > Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: > 01/04/10 04:54:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group cake-php+at http://groups.google.com/group/cake-php?hl=en No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 04:54:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
Yes you can. Just put all inside your public_html directory (assuming that user directories are enabled) or a subdirectory of public_html. It might be that .htaccess files are not handled for user directories. If so, check the file app/config/core.php and enable rewriting by CakePHP. On 4 jan 2010, at 21:29, Fred Riley wrote: > This has to be a FAQ, but I can't find a CakePHP FAQ anywhere so here > goes anyway: can CakePHP run on a *nix system in a user account? That > is, with a URL such as www.anyoldhost.com/~username/myapp. It's pretty > crucial that I know this as although I've full control over my > localhost installation I don't have root privileges on our > institutional Unix system and will have to run Cake apps in user > accounts. If it can run in user accounts, are there any special > configs that need to be applied? > > This has come to mind because I've been trying the Sitepoint Notes > tutorial (http://articles.sitepoint.com/print/application-development- > cakephp|Sitepoint tutorial) on a Macbook running OS/X and XAMPP. If I > put Cake into Users/username/Sites/cake_1.2.5 and try the URL > localhost/~username/cake_1.2.5/ in a browser, it fails with a 404 > if .htaccess is present in Cake root on account of the rewrite > directive. Removing .htaccess displays index.php ok but without a > rewrite the tutorial falls apart (the URL localhost/~username/ > cake_1.2.5/notes/ fails, for instance). On localhost I could install > cakePHP as root user for testing, but there'd be little point in > testing if I couldn't deploy it on our institutional server. > > If there is a FAQ do please point me to it as I don't like asking > RTFFAQ questions. Thanks. > > Fred > University of Nottingham > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en -- Kees de Bruin "A vacation is having nothing to do and all day to do it in" Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: MySQL takeover by Oracle - petition
> > Also as I said, MySQL isn't competition to > them, both are targeted to different markets. Five years ago, yes. But now, no. I worked both in finance and telecom industry and felt MySQL heat. Just take a look at BI, ERP and CRM world, you will see MySQL there already to some extent. > Do you think Oracle will some day drop their prices up to the > point that a SMB will be able to pay a license for it ? > Oracle database is not a sole product owned by Oracle. As you may know, you can download and install Oracle database for free. Oracle 10g Express Edition was ever promoted as MySQL alternative. But moreover, Oracle is actually a big business application player. They offer a lot of solid products based on their own Oracle RDMS. Their competitors offer the same stack with or without Oracle database support. MySQL is an option. Now by making MySQL future uncertain, Oracle makes IT solution buyers think again about their competitors who promote MySQL as an option and the concept of no vendor lock-in. MySQL is not a direct threat to Oracle yet. But its ecosystem, such as ISVs, as I believe, makes Oracle feel some heat. > > And in the remote case that the petition manages to make Oracle sell > off MySQL to comply withe EU terms, who will buy it ? who can > guarantee that someone more evil, for example MS or IBM doesn't buy it > ? that would be even worse. It would need to be bought by someone big > but that doesn't already have a database, As I see it, while Oracle > can make money from it they will continue to invest on it to improve > it to make it a better competitor in markets where Oracle database > can't go because of it's astronomic price. Probably the only thing > that will not ever happen is that we will not see MySQL replacing > Oracle someday, but that would not ever happen even if they still were > a standalone company. > > [1] > http://www.euractiv.com/en/infosociety/oracle-sun-offer-win-eu-approval/article-188311 > > Juancho > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: MySQL takeover by Oracle - petition
On Tue, Jan 5, 2010 at 9:15 AM, Dinh wrote: > Is it trustworthy? Oracle is not friendly to open source at all. They can > kill MySQL just by delaying to fix bugs. MySQL development is rather open. > It is quite opposite to Oracle style. > AFAIK it was one of the conditions imposed by US and the EU to approve the deal[1], so at least for the next five years they will have to continue to support MySQL. Also as I said, MySQL isn't competition to them, both are targeted to different markets. Their competition is MS SQL server and others, and MySQL will help them to compete in that market. Do you think Oracle will some day drop their prices up to the point that a SMB will be able to pay a license for it ? I don't think so. Probably they will overcharge for a MySQL support contract, but it's open source nature will make that other companies offer a cheaper support for it. And in the remote case that the petition manages to make Oracle sell off MySQL to comply withe EU terms, who will buy it ? who can guarantee that someone more evil, for example MS or IBM doesn't buy it ? that would be even worse. It would need to be bought by someone big but that doesn't already have a database, As I see it, while Oracle can make money from it they will continue to invest on it to improve it to make it a better competitor in markets where Oracle database can't go because of it's astronomic price. Probably the only thing that will not ever happen is that we will not see MySQL replacing Oracle someday, but that would not ever happen even if they still were a standalone company. [1] http://www.euractiv.com/en/infosociety/oracle-sun-offer-win-eu-approval/article-188311 Juancho Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Count column in index view
One more issue that has deflated my initial euphoria... The results don't paginate. How can I rectify that? On Jan 2, 4:53 am, Jeremy Burns wrote: > A success! Using your self created join code I arrived at this: > > $results = $this->LocationType->find( > 'all', > array( > 'contain' => false, > 'joins' => array( > array( > 'table' => 'locations', > 'type' => 'left', > 'alias' => 'Location', > 'foreignKey' => false, > 'conditions' => array('LocationType.id = > Location.location_type_id') > ) > ), > 'fields' => array('LocationType.id', 'LocationType.name', > 'COUNT(Location.id) as location_count'), > 'group' => array('LocationType.id', 'LocationType.name'), > ) > ); > > ...which works. Still seams long handed to me though. > > On Jan 2, 4:49 am, Jeremy Burns wrote: > > > > > I have changed my code slightly from: > > > $results = $this->LocationType->Location->find( > > to > > $results = $this->LocationType->find( > > > This does not error, but only produces the location_types that have > > locations. Therefore the results are still incomplete. > > > On Jan 2, 4:45 am, Jeremy Burns wrote: > > > > Hi John > > > > Thanks for this, but I still cannot get this to return the results I > > > need. I note that in your example the 'parent' is the author and the > > > child is the article. In my example the parent is the location_type > > > and the child is the location. Your code would exist (and work) within > > > the child (i.e. article or location) controller, whereas I need it to > > > run in the parent (i.e author or location_type) controller. When I try > > > to switch the code around I run into all sorts of errors. For example, > > > if I use your unbinding and then binding method... > > > > $this->LocationType->unbindModel( array('hasMany' => array > > > ('Location'))); > > > $this->LocationType->bindModel( array('hasOne' => array('Location'))); > > > $results = $this->LocationType->Location->find( > > > 'all', > > > array( > > > 'contain' => array('Location'), > > > 'fields' => array('LocationType.id', 'LocationType.name', > > > 'COUNT > > > (Location.id) as location_count'), > > > 'conditions' => array('Location.id' => array(1,2,3,4)), > > > 'group' => array('LocationType.id', 'LocationType.name'), > > > ) > > > ); > > > > ...it triggers the error: > > > > Model "Location" is not associated with model "Location" > > > ...which (by process of elimination) is triggered by the line: > > > > 'contain' => array('Location') > > > > Bizzarre. > > > > I also fiddled around with the self created join method with no > > > success. > > > > It strikes me that you and I have put a lot of effort into delivering > > > something extremely simple that appears to be a bug in the core code. > > > Would you agree? If so (and there are no other suggestions > > > forthcoming!) then i propose I raise a ticket. > > > > On Dec 30 2009, 10:15 am, John Andersen > > > wrote: > > > > > With the hasOne relationship, the query looks like: > > > > [code] > > > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as > > > > article_count FROM `authors` AS `Author` LEFT JOIN `articles` AS > > > > `Article` ON (`Article`.`author_id` = `Author`.`id`) WHERE > > > > `Author`.`id` IN (1, 2, 13) GROUP BY `Author`.`id`, `Author`.`name` > > > > [/code] > > > > > With the hasMany relationship, the query looks like: > > > > [code] > > > > SELECT `Author`.`id`, `Author`.`name`, COUNT(`Article`.`id`) as > > > > article_count FROM `authors` AS `Author` WHERE `Author`.`id` IN (1, 2, > > > > 13) GROUP BY `Author`.`id`, `Author`.`name` > > > > [/code] > > > > Contain does not assist in creating a LEFT JOIN, which is why > > > > Article.id is an unknown column! > > > > > As far as I remember, the issue is probably not in the Containable > > > > behaviour, but somewhere in DboSource, but I may be wrong here :) > > > > > There is another way: > > > > 1) Set contain equal false. > > > > 2) Define the joins yourself, as in the example below: > > > > [code] > > > > $results = $this->Article->Author->find( > > > > 'all', > > > > array( > > > > 'contain' => false, > > > > 'joins' => array( > > > > array( > > > > 'table' => 'articles', > > > > 'type' => 'left', > > > > 'alias' => 'Article', > > > > 'foreignKey' => false, > > > > 'conditions' => array('Article.author_id = > > > > Author.id') > > > > ) > > > > ), > > > > 'fields' => array('Author.id', 'Author.name', 'COUNT > > > > (Article.id) as article_count'), > > > > 'group' => array('Author.id
Re: MySQL takeover by Oracle - petition
Is it trustworthy? Oracle is not friendly to open source at all. They can kill MySQL just by delaying to fix bugs. MySQL development is rather open. It is quite opposite to Oracle style. I think you are overreacting, have you read Oracle's public position > on this ? I think not: > > > http://www.marketwire.com/press-release/Oracle-Corporation-NASDAQ-ORCL-109.html > > basically it's a commitment to continue to develop and support MySQL > and it's customers (including increasing R&D budget of MySQL). Oracle > has no reason to end MySQL, they fit perfectly in their portfolio to > compete against MS SQL server in the SMB market. Oracle DB is too > expensive for a SMB to buy it so it will never go there, that's why > they need MySQL. IMO, those petitions and sites of "save MySQL" only > spreads FUD which is not good. Have you browsed Oracle's website and > research your self what is their position on this? take a look at this > FAQ on Sun acquisition: > > http://www.oracle.com/us/sun/038563.pdf > > There is, at least for now, nothing to worry about. It's the same FUD > and negative vibes that appeared when Sun bought MySQL. What happened? > nothing... > > Juancho Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: MySQL takeover by Oracle - petition
Isn't it open source? Not the first time someone made a fork of it - including the original author. :) On Jan 4, 10:31 pm, Juan Luis Baptiste wrote: > On Mon, Jan 4, 2010 at 10:05 AM, hashmich wrote: > > Oracle is going to take over Sun Microsystems - who are the owner of > > the copyrights for MySQL. > > I think you can imagine, what's the meaning of MySQL being taken over > > by its direct commercial competitor. > > I think you are overreacting, have you read Oracle's public position > on this ? I think not: > > http://www.marketwire.com/press-release/Oracle-Corporation-NASDAQ-ORC... > > basically it's a commitment to continue to develop and support MySQL > and it's customers (including increasing R&D budget of MySQL). Oracle > has no reason to end MySQL, they fit perfectly in their portfolio to > compete against MS SQL server in the SMB market. Oracle DB is too > expensive for a SMB to buy it so it will never go there, that's why > they need MySQL. IMO, those petitions and sites of "save MySQL" only > spreads FUD which is not good. Have you browsed Oracle's website and > research your self what is their position on this? take a look at this > FAQ on Sun acquisition: > > http://www.oracle.com/us/sun/038563.pdf > > There is, at least for now, nothing to worry about. It's the same FUD > and negative vibes that appeared when Sun bought MySQL. What happened? > nothing... > > Juancho Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: update db insted of insert if entry already exists
Hi Donnerbeil, The problem is likely down to the fact that you're doing a read of the existing Rating record expecting that to set the id before the save, but you're then passing in a full data set (without and id set) to the save method. Maybe try replacing: > $this->Rating->read(null,$entry['Rating']['id']); with: $this->data['id'] = $entry['Rating']['id']; Regards, Ian IMiJ Ltd http://www.imij.co.uk http://www.ianmjones.com http://twitter.com/ianmjones On 5 Jan 2010, at 12:44, donnerbeil wrote: > Hi all, > > I have a simple rating controller, so users can rate each other. I > don't know the reason, but every few days the whole ratings table in > the database is empty. All ratings are lost. Here is my ratings > controller as I use it. There are no other methods or anything else. I > exactly use it this way. I use cake 1.2. > > Can you find the bug or do you have any suggestions, how I could solve > the issue. What I want to do is: If the voter has already voted > (rated) the user, the old rating should be updated. Otherwise a new > entry in the db should be made. in other words: If a given voter- > profile pair already exists in the db, update the row, otherwise make > a new entry. > > And thats the controller: > > class RatingsController extends AppController { > > var $name = 'Ratings'; > > function beforeFilter(){ > parent::beforeFilter(); > } > > function add($id,$points){ > //user tries to rate himself > if($id==$this->auth_user['Profile']['id']){ > $this->Session->setFlash(__('You cannot rate > yourself',true),'notice'); > } > else{ > > //check if there is already a rating. If so read it in > order to > update instead of insert > > $entry=$this->Rating->find('first',array('conditions'=>array > ('Rating.profile_id'=>(int)$id,'Rating.voter_id'=>$this->auth_user > ['Profile']['id']),'recursive'=>-1)); > if(!empty($entry['Rating']['id'])){ > > $this->Rating->read(null,$entry['Rating']['id']); > } > $this->data['profile_id']=(int)$id; > > $this->data['voter_id']=$this->auth_user['Profile']['id']; > $this->data['points']=(int)$points; > if($this->Rating->save($this->data)){ > $this->Session->setFlash(__('Your rating has > been saved.', > true),'success'); > } > else{ > $this->Session->setFlash(__('Page not found.', > true),'error'); > } > > } > $this->redirect($this->referer()); > } > > > > } > ?> > > Thanks > > Donnerbeil > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.com For more options, visit this group at > http://groups.google.com/group/cake-php?hl=en Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Can CakePHP run in a user account?
Hi Fred, >From what I understand about XAMPP, the document root is in /Applications/XAMPP/htdocs, so I would put the CakePHP files in there first and try accessing it again. Also make sure that the default Apache is not running or you are serving XAMPP from a different port. HTH, Adeola. 2010/1/4 Fred Riley > This has to be a FAQ, but I can't find a CakePHP FAQ anywhere so here > goes anyway: can CakePHP run on a *nix system in a user account? That > is, with a URL such as www.anyoldhost.com/~username/myapp. It's pretty > crucial that I know this as although I've full control over my > localhost installation I don't have root privileges on our > institutional Unix system and will have to run Cake apps in user > accounts. If it can run in user accounts, are there any special > configs that need to be applied? > > This has come to mind because I've been trying the Sitepoint Notes > tutorial (http://articles.sitepoint.com/print/application-development- > cakephp|Sitepoint tutorial) on a Macbook running OS/X and XAMPP. If I > put Cake into Users/username/Sites/cake_1.2.5 and try the URL > localhost/~username/cake_1.2.5/ in a browser, it fails with a 404 > if .htaccess is present in Cake root on account of the rewrite > directive. Removing .htaccess displays index.php ok but without a > rewrite the tutorial falls apart (the URL localhost/~username/ > cake_1.2.5/notes/ fails, for instance). On localhost I could install > cakePHP as root user for testing, but there'd be little point in > testing if I couldn't deploy it on our institutional server. > > If there is a FAQ do please point me to it as I don't like asking > RTFFAQ questions. Thanks. > > Fred > University of Nottingham > > Check out the new CakePHP Questions site http://cakeqs.org and help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.comFor > more options, visit this group at > http://groups.google.com/group/cake-php?hl=en > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key).
It's easy, the only thing that you have to do is $data = $this->State->find('all', array('fields' => 'State.id, Provincia.state')); $state_list = Set::combine($data, '{n}.State.id', '{n}.State.state'); $this->set('state_list', $state_list); With this the select will show the state names and in the $this->data from the form you will get the state id of the selected state. Don't forget to add 'options' => $state_list in the options of the select input in the form. -- Forwarded message -- From: Guran Date: 4 ene, 23:36 Subject: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key). To: CakePHP I am a new baker and I am stuck in the dough. I am trying to insert a option/select drop down but cannot get the field I need to show in the drop down I have the following tables: CREATE TABLE IF NOT EXISTS `employees` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `state_id` int(11) unsigned NOT NULL, `name` varchar(50) NOT NULL, `email` varchar(30) DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `employees.state_id` (`state_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; CREATE TABLE IF NOT EXISTS `states` ( `id` int(11) unsigned NOT NULL AUTO_INCREMENT, `state` varchar(2) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ; INSERT INTO `states` (`id`, `state`) VALUES (1, 'AL'), (2, 'AR'), (3, 'AZ'), (4, 'CA'), (5, 'CO'), (6, 'CT'), (7, 'DC'), (8, 'DE'); The following two models are generated through console tool cake bake model using the default options provided. class State extends AppModel { var $name = 'State'; var $belongsTo = array( 'Employee' => array( 'className' => 'Employee', 'foreignKey' => 'state_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); } class Employee extends AppModel { var $name = 'Employee'; var $belongsTo = array( 'State' => array( 'className' => 'State', 'foreignKey' => 'state_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); } I would like to show the "states.state" field but all I get is the "states.id" field in the dropdown. Where have I gone wrong? Any help is appreciated! It's easy, the only thing that you have to do is $data = $this->State->find('all', array('fields' => 'State.id, Provincia.state')); $state_list = Set::combine($data, '{n}.State.id', '{n}.State.state'); $this->set('state_list', $state_list); With this the select will show the state names and in the $this->data from the form you will get the state id of the selected state. Don't forget to add 'options' => $state_list in the options of the select input in the form. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Secret URLs
Maybe this will help: http://bakery.cakephp.org/articles/view/encrypting-urls On Jan 1, 11:54 am, anka wrote: > Hi @all, > > I have a (almost) simple question! Is it possible to make all cake php > REST URLs unreadable? What I mean is, that a given REST URL like ".../ > user/delete/10" is very simple to read for a human and it is very > simple to guess that I can call this URL with any ID i want. So it > would be very helpful, to generate URLs like ".../ > aasdf080234ljasdflk234" or something like that so no human can modify > the URL within the browser and to avoid anoying side effects within > the system. > > Thanks and best regards, > Andreas Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
update db insted of insert if entry already exists
Hi all, I have a simple rating controller, so users can rate each other. I don't know the reason, but every few days the whole ratings table in the database is empty. All ratings are lost. Here is my ratings controller as I use it. There are no other methods or anything else. I exactly use it this way. I use cake 1.2. Can you find the bug or do you have any suggestions, how I could solve the issue. What I want to do is: If the voter has already voted (rated) the user, the old rating should be updated. Otherwise a new entry in the db should be made. in other words: If a given voter- profile pair already exists in the db, update the row, otherwise make a new entry. And thats the controller: auth_user['Profile']['id']){ $this->Session->setFlash(__('You cannot rate yourself',true),'notice'); } else{ //check if there is already a rating. If so read it in order to update instead of insert $entry=$this->Rating->find('first',array('conditions'=>array ('Rating.profile_id'=>(int)$id,'Rating.voter_id'=>$this->auth_user ['Profile']['id']),'recursive'=>-1)); if(!empty($entry['Rating']['id'])){ $this->Rating->read(null,$entry['Rating']['id']); } $this->data['profile_id']=(int)$id; $this->data['voter_id']=$this->auth_user['Profile']['id']; $this->data['points']=(int)$points; if($this->Rating->save($this->data)){ $this->Session->setFlash(__('Your rating has been saved.', true),'success'); } else{ $this->Session->setFlash(__('Page not found.', true),'error'); } } $this->redirect($this->referer()); } } ?> Thanks Donnerbeil Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key).
This suggestion by Jeremy looks all right: $states = $this->Employee->State->find('list'); $this->set(compact('states')); My hint would be to change your database schema to state: id, name or state: id, title as state: id, state is redundant anyway. The magic that will appear is cake auto detecting name (or title) as the display field to use with find('list'). If you do not want to change the schema you can use var $displayField. See the book. Regards ionas On Jan 4, 11:36 pm, Guran wrote: > I am a new baker and I am stuck in the dough. I am trying to insert a > option/select drop down but cannot get the field I need to show in the > drop down > I have the following tables: > > CREATE TABLE IF NOT EXISTS `employees` ( > `id` int(11) unsigned NOT NULL AUTO_INCREMENT, > `state_id` int(11) unsigned NOT NULL, > `name` varchar(50) NOT NULL, > `email` varchar(30) DEFAULT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `employees.state_id` (`state_id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > CREATE TABLE IF NOT EXISTS `states` ( > `id` int(11) unsigned NOT NULL AUTO_INCREMENT, > `state` varchar(2) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ; > > INSERT INTO `states` (`id`, `state`) VALUES > (1, 'AL'), > (2, 'AR'), > (3, 'AZ'), > (4, 'CA'), > (5, 'CO'), > (6, 'CT'), > (7, 'DC'), > (8, 'DE'); > > The following two models are generated through console tool cake bake > model using the default options provided. > > class State extends AppModel { > var $name = 'State'; > var $belongsTo = array( > 'Employee' => array( > 'className' => 'Employee', > 'foreignKey' => 'state_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > } > > class Employee extends AppModel { > var $name = 'Employee'; > var $belongsTo = array( > 'State' => array( > 'className' => 'State', > 'foreignKey' => 'state_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > } > > I would like to show the "states.state" field but all I get is the > "states.id" field in the dropdown. Where have I gone wrong? > > Any help is appreciated! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Secret URLs
Hi again, I am open to learn, so please tell me, whats the benefit of url obscurity if not protecting against CSRF. A large german social network uses that to protect against CSRF - though they do not use UUIDs. Just links like domain.tld/long_random_looking_stuff_here, it works against mining too. I do not think UUIDs work against mining so well as they are not meant to be very random but very unique (e.g. following a pattern). The above poster for sure wants to take a look at the security component, as I mentioned. Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error Placement / Styles
Well, now that I took a better look at your code, I don't understand why you don't use the standard cake form field and error generation, because that should be all you need :) Example HTML from my own code where the field has an error - it is mandatory: [code] print( $form->input( 'Reporter.email', array('label' => __ ('visitors_email',true), 'class' => 'email', 'error' => array ('report_email_rule' => __('report_email_rule',true) ) ) ) ); [/code] produces the following HTML when I don't enter an e-mail address! [code] E-mail reporter_email_rule [/code] Observe that the form helper has automatically inserted the error class in the div element! Enjoy, John On Jan 5, 10:15 am, "Dave" wrote: > Thanks John, > > I did set the 'error' => false so no message shows. But how do I get the > error class to end up inside the > > I tried an assortment of attemps with > > ??? > But nothing. > > Ideas? > > Thanks, > > Dave > > -Original Message- > From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf > > Of John Andersen > Sent: January-05-10 4:35 AM > To: CakePHP > Subject: Re: Error Placement / Styles > > Yes you can! > In the form field, add the option 'error' => false to disable the automatic > error message. Then use the form helpers error method for the field and > place it whereever you want. > Seehttp://book.cakephp.org/view/721/error > Enjoy, > John > > On Jan 5, 9:46 am, "Dave" wrote: > > Is it possible to determine where the error class gets added? > > > for example: > > > > > > > input('User.password', array('label' => > > 'Password:')); ?> > > Required: > > Password must be minimum of 8 characters. > > input('User.username', array('label' => > > 'Select a Username:')); ?> > > Required: > > Username can never be changed. > > > > > > > > So if a field fails i would like to add the error class to the so > > the entire row gets the error class like > > > Thanks > > > Dave > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others > with their CakePHP related questions. > > 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 > cake-php+unsubscr...@googlegroups.com For more options, visit this group > cake-php+athttp://groups.google.com/group/cake-php?hl=en > No virus found in this incoming message. > Checked by AVG -www.avg.com > Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 > 04:54:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How can I get an option/select drop down to populate with a table.myfield instead of the table.id (primary key).
What you have here looks correct, except that your $belongsTo definition in your State model looks wrong. Shouldn't that be a $hasMany definition? That means that an Employee belongs to a State, and a State has many Employees. The drop down is displayed in a view and the contents of the drop down are populated in the controller action that calls the view. In the function (probably edit or add, I would guess) add these lines: $states = $this->Employee->State->find('list'); $this->set(compact('states')); compact can take more than one variable. So if you end up with more than one drop down repeat the first line and add the new variable (minus the $ sign) to the compact array, e.g. $this->set(compact ('states', 'countries')); In your view, your drop down is created like this: echo $form->input('state_id', array('empty' => true)); Cake will use the contents of the $state array to populate the drop down, displaying the name of the state. The empty option means that nothing is selected by default. Without it, your form will display the first entry and assume that the user wants to select that one. Hope that helps. On Jan 4, 10:36 pm, Guran wrote: > I am a new baker and I am stuck in the dough. I am trying to insert a > option/select drop down but cannot get the field I need to show in the > drop down > I have the following tables: > > CREATE TABLE IF NOT EXISTS `employees` ( > `id` int(11) unsigned NOT NULL AUTO_INCREMENT, > `state_id` int(11) unsigned NOT NULL, > `name` varchar(50) NOT NULL, > `email` varchar(30) DEFAULT NULL, > PRIMARY KEY (`id`), > UNIQUE KEY `employees.state_id` (`state_id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; > > CREATE TABLE IF NOT EXISTS `states` ( > `id` int(11) unsigned NOT NULL AUTO_INCREMENT, > `state` varchar(2) NOT NULL, > PRIMARY KEY (`id`) > ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=51 ; > > INSERT INTO `states` (`id`, `state`) VALUES > (1, 'AL'), > (2, 'AR'), > (3, 'AZ'), > (4, 'CA'), > (5, 'CO'), > (6, 'CT'), > (7, 'DC'), > (8, 'DE'); > > The following two models are generated through console tool cake bake > model using the default options provided. > > class State extends AppModel { > var $name = 'State'; > var $belongsTo = array( > 'Employee' => array( > 'className' => 'Employee', > 'foreignKey' => 'state_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > } > > class Employee extends AppModel { > var $name = 'Employee'; > var $belongsTo = array( > 'State' => array( > 'className' => 'State', > 'foreignKey' => 'state_id', > 'conditions' => '', > 'fields' => '', > 'order' => '' > ) > ); > > } > > I would like to show the "states.state" field but all I get is the > "states.id" field in the dropdown. Where have I gone wrong? > > Any help is appreciated! Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error Placement / Styles
Try this, error('User.password')){?> class='error'' > Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: How do I use the email component?
Here you go - this covers the basics. Using the component is actually quite simple: http://www.jeremy-burns.co.uk/2009/12/cakephp-sending-email-using-the-email-component/ On Jan 5, 1:47 am, otisjs01 wrote: > Hello, > > I am new to CakePHP and trying desperately to learn! > > My most recent struggle is with the Email Component. > > I have a contract. When I create the contract, I add a user. When I > save the new contract...for the first time, I want to send an email to > the user in that contract that allows them to click on a link back to > the contract, and then accept or reject the contract. > > How do I send this email? > > The more details I can get, answer-wise, the better. Everything I have > read out there is surprisingly confusing. Do I need to configure smtp > settings? How do I grab the user in the contract after it has been > saved and pass it and the link to the contract on to the email? How do > I know if the email has been sent, without going and checking my email > every single time? > > Here is the code I have in my contracts_controller.php for the email > sending function: (A Contract belongsTo a User, and a User hasMany > Contracts.) > > function _sendContractEmail($id) { > $this->Email->smtpOptions = array( > 'port'=>'465', > 'timeout'=>'30', > 'host'=>'ssl://smtp.gmail.com', > 'username'=>'username', > 'password'=>'password' > ); > $this->Email->delivery = 'smtp'; > $User = $this->Contract->User->read(null,$id); > $this->Email->to = 'jerem...@jeremiahotis.com'; > $this->Email->subject = ''; > $this->Email->replyTo = 'no-re...@goodvaluation.com'; > $this->Email->from = 'Jeremiah Oits > '; > $this->Email->template = 'simple_message'; > $this->Email->sendAs = 'html'; > $this->set('User', $User); > $this->Email->_debug = true; > $this->Email->send('Test Email'); > $this->redirect(array('controller'=>'contracts', > 'action'=>'index')); > } > > Here is the code I have in my contracts_controller.php add() function: > > function add() { > if (!empty($this->data)) { > $this->Contract->create(); > if ($this->Contract->save($this->data)) { > $this->Session->setFlash(__('The Contract has been > saved', true)); > $this->_sendContractEmail($this->Contract->User->id); > } else { > $this->Session->setFlash(__('The Contract could not be > saved. Please, try again.', true)); > } > > And, this is at the top of my contracts_controller.php file after the > $name and $helpers: > > var $components = array('Email'); > > I guess I should point out that I was having trouble with the > template, so to test it, I included the body of the email directly in > the send(), and I specified the to email address rather than using a > variable. Still...nothing! No error, no email. > > Any help would be greatly appreciated! I really have no idea what I am > doing wrong! > > Thanks, > > Jeremiah Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
RE: Error Placement / Styles
Thanks John, I did set the 'error' => false so no message shows. But how do I get the error class to end up inside the I tried an assortment of attemps with ??? But nothing. Ideas? Thanks, Dave -Original Message- From: cake-php@googlegroups.com [mailto:cake-...@googlegroups.com] On Behalf Of John Andersen Sent: January-05-10 4:35 AM To: CakePHP Subject: Re: Error Placement / Styles Yes you can! In the form field, add the option 'error' => false to disable the automatic error message. Then use the form helpers error method for the field and place it whereever you want. See http://book.cakephp.org/view/721/error Enjoy, John On Jan 5, 9:46 am, "Dave" wrote: > Is it possible to determine where the error class gets added? > > for example: > > > > input('User.password', array('label' => > 'Password:')); ?> > Required: > Password must be minimum of 8 characters. > input('User.username', array('label' => > 'Select a Username:')); ?> > Required: > Username can never be changed. > > > > > So if a field fails i would like to add the error class to the so > the entire row gets the error class like > > Thanks > > Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group cake-php+at http://groups.google.com/group/cake-php?hl=en No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.725 / Virus Database: 270.14.124/2599 - Release Date: 01/04/10 04:54:00 Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
Re: Error Placement / Styles
Yes you can! In the form field, add the option 'error' => false to disable the automatic error message. Then use the form helpers error method for the field and place it whereever you want. See http://book.cakephp.org/view/721/error Enjoy, John On Jan 5, 9:46 am, "Dave" wrote: > Is it possible to determine where the error class gets added? > > for example: > > > > input('User.password', array('label' => > 'Password:')); ?> > Required: > Password must be minimum of 8 characters. > input('User.username', array('label' => 'Select a > Username:')); ?> > Required: > Username can never be changed. > > > > > So if a field fails i would like to add the error class to the so the > entire row gets the error class like > > Thanks > > Dave Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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 cake-php+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en