How to update but if field is empty not
I need to run a save/update query but only update those fields that aren't empty. My form contains a FILE field and if I don't upload any file then when the save() is executed this field goes blank even if previous data is presented so how can I save/updated but onlye the fields with content to update? Cheers and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
How to wrap the active "number" link in tags at Paginator Helper
Hi every: Because I'm using Bootstrap from Twitter and want to prettify my page ;) I need to set a {number} to the active element in Paginator Helper. Right now my code looks as follow: Paginator->prev('<< ', array('tag' => 'li'), null, array('class' => 'prev disabled', 'tag' => 'li')); echo $this->Paginator->numbers(array('separator' => '', 'tag' => 'li', 'class' => 'active', 'first' => __('First page'), 'last' => __('Last page'))); echo $this->Paginator->next(' >>', array('tag' => 'li'), null, array('class' => 'next disabled', 'tag' => 'li')); ?> But I not found a way for wrap the active link in a {page_number_active} otherwise the LI is generated in this way: {page_number_active}. This only happen with the active link the rest of them is wrapped inside a element. Any help on this? Cheers and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
It's possible to use Uploader plugin in this case .... ???
Hi every: After a lot of Google hours and finally I found a plugin for handle multiple files uploads. The address for this plugin is this one: http://milesj.me/code/cakephp/uploader#installation. Because I'm newbie with Cake I need your help on some parts. I have a table called "Records" and other called "Documents" and a relationship between them as 1 record can have many documents so it's 1:m. Now in the Model for table Records I have this code: array( 'notempty' => array( 'rule' => array('notempty'), 'message' => 'The field can not be empty', ), ), 'lastname' => array( 'notempty' => array( 'rule' => array('notempty'), 'message' => 'The field can not be empty', ), ), 'email' => array( 'email' => array( 'rule' => array('email'), 'message' => 'The email address is not valid', ), ), ); public $belongsTo = array( 'Country' => array( 'className' => 'Country', 'foreignKey' => 'country_id', 'conditions' => '', 'fields' => '', 'order' => '' ) ); public $hasMany = array( 'Document' => array( 'className' => 'Document', 'foreignKey' => 'record_id', 'dependent' => true, 'conditions' => '', 'fields' => '', 'order' => '', 'limit' => '', 'offset' => '', 'exclusive' => '', 'finderQuery' => '', 'counterQuery' => '' ) ); public $actsAs = array( 'Uploader.Attachment' => array( 'fileName' => array( 'name'=> 'formatFileName',// Name of the function to use to format filenames 'dbColumn'=> 'uploadPath', // The database column name to save the path to 'importFrom'=> '',// Path or URL to import file 'defaultPath'=> '',// Default file path if no upload present 'maxNameLength'=> 30,// Max file name length 'overwrite'=> true,// Overwrite file with same name if it exists 'stopSave'=> true,// Stop the model save() if upload fails 'allowEmpty'=> true,// Allow an empty file upload to continue 'transforms'=> array(),// What transformations to do on images: scale, resize, etc 'metaColumns'=> array(// Mapping of meta data to database fields 'ext' => '', 'type' => '', 'size' => '', 'group' => '', 'width' => '', 'height' => '', 'filesize' => '' ) ) ) ); } But as I said before the attachment or uploaded files information it's in Documents table and not in Records so my first question around this plugin is: can I save the file related information in the Documents table? If so how? I try to contact the author but at this moment doesn't reply yet. Cheers and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: How to retrieve all records from related tables?
Read which part of the manual? All or just Conventions related? I'm having a lot of headaches with this Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Sat, Feb 25, 2012 at 10:22 AM, Tilen Majerle wrote: > foreign keys in http://pastebin.com/RdWzfria (this tables) are > incorrect. in all three tables you have " informations_id ", it should be > "information_id" > > > http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html<http://book.cakephp.org/2.0/en/models/associations-linking-models-together.html#belongsto> > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/2/25 reynie...@gmail.com > >> Hi: >> I have a table called "*informations*" (http://pastebin.com/h3UiUhpx) >> and also have this associated tables "educations", "attachments" and >> "experiences" (http://pastebin.com/RdWzfria) (please see pastebin URLs I >> put the code there to not ugly the post). As you may notice all this tables >> have a relationship with informations so data coming from informations form >> is saved there. I use bake for create the models, views and controllers for >> this tables. Now when I add all is fine except for the attachments because >> it's a FILE input type and I don't know how to handle this part so any help >> will be very appreciated but the problem here is when I try to edit any >> records for informations table because none record from the relations >> tables is showed and don't know the cause. The code for informations model >> is here: http://pastebin.com/bEY3beBw, for the Controller is here: >> http://pastebin.com/muAQn3aH and for the view is here: >> http://pastebin.com/AEhPPCX0, can any help to fix this? >> Cheers and thanks in advance >> Ing. Reynier Pérez Mira >> http://reynierpm.site90.com/ >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> 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 >> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
How to retrieve all records from related tables?
Hi: I have a table called "*informations*" (http://pastebin.com/h3UiUhpx) and also have this associated tables "educations", "attachments" and "experiences" (http://pastebin.com/RdWzfria) (please see pastebin URLs I put the code there to not ugly the post). As you may notice all this tables have a relationship with informations so data coming from informations form is saved there. I use bake for create the models, views and controllers for this tables. Now when I add all is fine except for the attachments because it's a FILE input type and I don't know how to handle this part so any help will be very appreciated but the problem here is when I try to edit any records for informations table because none record from the relations tables is showed and don't know the cause. The code for informations model is here: http://pastebin.com/bEY3beBw, for the Controller is here: http://pastebin.com/muAQn3aH and for the view is here: http://pastebin.com/AEhPPCX0, can any help to fix this? Cheers and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
How to handle FILE input type when saving form information?
Hi: I'm having some problems handling file uploads and database saving. I have a table where I need to store the route where uploaded files are saved but not know how to achieve this. I found this http://cakebaker.42dh.com/2006/04/15/file-upload-with-cakephp/ and I'm trying to adjust my code to fit the requirements. Now my code is this one: public function add() { if ($this->request->is('post') && is_uploaded_file($this->request->data['Information']['picture']['tmp_name'])) { // Handling file uploads $fileData = fread(fopen($this->request->data['Information']['picture']['tmp_name'], "r", $this->request->data['Information']['picture']['size'])); $this->data['Information']['name'] = $this->request->data['Information']['picture']['name']; $this->Information->create(); if ($this->Information->saveAll($this->request->data)) { $this->Session->setFlash(__('The information has been saved'), 'flash_success'); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The information could not be saved. Please, try again.'), 'flash_error'); } } $countries = $this->Information->Country->find('list'); $this->set(compact('countries')); } and have two questions around it: how to setup where uploaded files goes? how to add this route to query? I mean for save the route in my DB Any advice or help? Cheers Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: How I can set "class" atributte for a Form?
Thanks it works !! Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 6:06 PM, Tilen Majerle wrote: > $this->From->create('Information', array('class' => 'yourclassname')); > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/2/23 reynie...@gmail.com > >> Hi: >> I was reading the doc for Form Helper finding how to add "class" >> attribute to a tag but can't find how, can any point me in the right >> direction? I'm generating the form with this code: "echo >> $this->Form->create('Information');" >> >> Ing. Reynier Pérez Mira >> http://reynierpm.site90.com/ >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> 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 >> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
How I can set "class" atributte for a Form?
Hi: I was reading the doc for Form Helper finding how to add "class" attribute to a tag but can't find how, can any point me in the right direction? I'm generating the form with this code: "echo $this->Form->create('Information');" Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: The classic "Fatal error: Call to a member function find() on a non-object" for newbie
Ohhh thanks I miss this part now it works. Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 5:48 PM, jeremyharris wrote: > It's because the item Country does not exist on Information. Models are > always singular, so where you have Countries defined in your Information > belongsTo you should have Country instead. > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Error while trying to bake model for specific table
And? What's the solution for this problem? How I can fix this? Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 5:30 PM, jeremyharris wrote: > The model it is probably looking for is Person, which in english is the > singular of People. > > So PeopleController uses the Person model > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Problems with cake bake
Hi: I'm trying to bake one of my DB tables and this is what I'm doing: 1) Create (M)odel for TblInformations table 2) Create (M)odel for TblInformationTypes table 3) Create (V)iew for TblInformationTypes table but at this step I get stucked and this error appear: Error: Database table information for model Information was not found. #0 /var/www/html/jobapp/lib/Cake/Model/Model.php(3265): Model->setSource('information') #1 /var/www/html/jobapp/lib/Cake/Model/Model.php(1223): Model->getDataSource() #2 /var/www/html/jobapp/lib/Cake/Model/Model.php(1309): Model->schema() #3 /var/www/html/jobapp/lib/Cake/Model/Model.php(1295): Model->hasField('title', false) #4 /var/www/html/jobapp/lib/Cake/Model/Model.php(800): Model->hasField(Array) #5 /var/www/html/jobapp/lib/Cake/Console/Command/Task/ViewTask.php(459): Model->__get('displayField') #6 /var/www/html/jobapp/lib/Cake/Console/Command/Task/ViewTask.php(284): ViewTask->_associations(Object(TblInformationType)) #7 /var/www/html/jobapp/lib/Cake/Console/Command/Task/ViewTask.php(223): ViewTask->_loadController() #8 /var/www/html/jobapp/lib/Cake/Console/Command/Task/ViewTask.php(90): ViewTask->_interactive() #9 /var/www/html/jobapp/lib/Cake/Console/Command/BakeShell.php(110): ViewTask->execute() #10 /var/www/html/jobapp/lib/Cake/Console/Command/BakeShell.php(131): BakeShell->main() #11 /var/www/html/jobapp/lib/Cake/Console/Shell.php(389): BakeShell->main() #12 /var/www/html/jobapp/lib/Cake/Console/ShellDispatcher.php(177): Shell->runCommand(NULL, Array) #13 /var/www/html/jobapp/lib/Cake/Console/ShellDispatcher.php(69): ShellDispatcher->dispatch() #14 /var/www/html/jobapp/lib/Cake/Console/cake.php(24): ShellDispatcher::run(Array) #15 {main} Any help? What I'm miss or doing wrong? Cheers and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: Styles and JS not loaded
Ok sorry for that my bad I'm using ->script when should be ->css miss this mail :-( Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 9:19 AM, reynie...@gmail.com wrote: > Hi: > I'm trying to use Twitter Bootstrap for the look & feel of my application > but I must doing something wrong because does not work :-(. I've created a > file called default.ctp under View/Layouts folder and in this file I use > this code for styles: > > > > Html->script('bootstrap.min.css'); ?> > > > But it's not working because no
Re: Why data isn't showed?
Fine, it works now and I understand well this part, cheers and thanks Tilen Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 8:55 AM, Tilen Majerle wrote: > read manual again ! > > models names are Country (singularized and camelized), and controllers are > CountriesController (pluralized)) > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/2/23 reynie...@gmail.com > >> OK, I made some changes to my DB structure and also to my code but still >> getting errors, see below what I'm doing now. >> 1) Change the table from countries to country and also rename the >> composite PK from country_id to id >> 2) Change code in the Model, now looks like this: >> >> > class Country extends AppModel { >> public $name = 'Country'; >> } >> >> 3) Change code in the Controller: >> class CountryController extends AppController { >> public $name = 'Country'; >> public $helpers = array("Html", "Form"); >> public $components = array("Session"); >> >> public function edit($id = null) { >> $this->Country->id = $id; >> if ($this->request->is('get')) { >> $this->request->data = $this->Country->read(); >> } else { >> if ($this->Countries->save($this->request->data)) { >> $this->Session->setFlash(__('The country has been updated.')); >> $this->redirect(array('action' => 'index')); >> } else { >> $this->Session->setFlash(__('Unable to update the country.')); >> } >> } >> } >> >> But I get this error: >> Missing Database Table >> Error: Database table countries for model Country was not found. >> Why? >> Ing. Reynier Pérez Mira >> http://reynierpm.site90.com/ >> >> >> >> On Thu, Feb 23, 2012 at 8:29 AM, reynie...@gmail.com > > wrote: >> >>> So because CakePHP doesn't support compsite PK then the solution need to >>> be change the field country_id for id and also in all the tables. Reading >>> the conventions for Models I get one doubt and goes to oneToMany relations. >>> If I have one relation oneToMany between tables candidate and education and >>> I add the FK candidate_id in education table then CakePHP knows the >>> relation by default? This is correct? Please can you take a look at my DB >>> design and tell me if something is wrong there: >>> http://www.dropmocks.com/mBgrQq ? >>> >>> Ing. Reynier Pérez Mira >>> http://reynierpm.site90.com/ >>> >>> >>> >>> On Thu, Feb 23, 2012 at 7:40 AM, Tilen Majerle >>> wrote: >>> >>>> http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html >>>> >>>> >>>> look here, cakephp conventions >>>> -- >>>> Lep pozdrav, Tilen Majerle >>>> http://majerle.eu >>>> >>>> >>>> >>>> 2012/2/23 reynie...@gmail.com >>>> >>>>> Hi Tilen, I not understand your point here. As you said I have >>>>> country_id as PK and my table is Countries not Country so my model code is >>>>> this one (Countries.php): >>>>> >>>>> class Countries extends AppModel { >>>>> public $name = 'Countries'; >>>>> } >>>>> >>>>> then if I use $this->Country->id = $id doesn't work and if I >>>>> use $this->Countries->country_id = $id doesn't work too. Which should be >>>>> the solution? Change my table structure or what? >>>>> >>>>> Ing. Reynier Pérez Mira >>>>> http://reynierpm.site90.com/ >>>>> >>>>> >>>>> >>>>> On Thu, Feb 23, 2012 at 5:02 AM, Tilen Majerle < >>>>> tilen.maje...@gmail.com> wrote: >>>>> >>>>>> you have "country_id" as your primary key in table ? >>>>>> >>>>>> and "Countries" for modelname ? >>>>>> it should be "Country" right ? :) >>>>>> >>>>>> $this->Countries->country_id = $id; //this is wrong >>>>>> here should be ALWAYS "id", so $this->Countries->id = $id; >>>>>> >>>>>> but u should use camelized and singularized name, so >>>>>> $this->Country->i
Styles and JS not loaded
Hi: I'm trying to use Twitter Bootstrap for the look & feel of my application but I must doing something wrong because does not work :-(. I've created a file called default.ctp under View/Layouts folder and in this file I use this code for styles: Html->script('bootstrap.min.css'); ?> But it's not working because no
Re: Why data isn't showed?
OK, I made some changes to my DB structure and also to my code but still getting errors, see below what I'm doing now. 1) Change the table from countries to country and also rename the composite PK from country_id to id 2) Change code in the Model, now looks like this: Country->id = $id; if ($this->request->is('get')) { $this->request->data = $this->Country->read(); } else { if ($this->Countries->save($this->request->data)) { $this->Session->setFlash(__('The country has been updated.')); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('Unable to update the country.')); } } } But I get this error: Missing Database Table Error: Database table countries for model Country was not found. Why? Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 8:29 AM, reynie...@gmail.com wrote: > So because CakePHP doesn't support compsite PK then the solution need to > be change the field country_id for id and also in all the tables. Reading > the conventions for Models I get one doubt and goes to oneToMany relations. > If I have one relation oneToMany between tables candidate and education and > I add the FK candidate_id in education table then CakePHP knows the > relation by default? This is correct? Please can you take a look at my DB > design and tell me if something is wrong there: > http://www.dropmocks.com/mBgrQq ? > > Ing. Reynier Pérez Mira > http://reynierpm.site90.com/ > > > > On Thu, Feb 23, 2012 at 7:40 AM, Tilen Majerle wrote: > >> http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html >> >> look here, cakephp conventions >> -- >> Lep pozdrav, Tilen Majerle >> http://majerle.eu >> >> >> >> 2012/2/23 reynie...@gmail.com >> >>> Hi Tilen, I not understand your point here. As you said I have >>> country_id as PK and my table is Countries not Country so my model code is >>> this one (Countries.php): >>> >>> class Countries extends AppModel { >>> public $name = 'Countries'; >>> } >>> >>> then if I use $this->Country->id = $id doesn't work and if I >>> use $this->Countries->country_id = $id doesn't work too. Which should be >>> the solution? Change my table structure or what? >>> >>> Ing. Reynier Pérez Mira >>> http://reynierpm.site90.com/ >>> >>> >>> >>> On Thu, Feb 23, 2012 at 5:02 AM, Tilen Majerle >>> wrote: >>> >>>> you have "country_id" as your primary key in table ? >>>> >>>> and "Countries" for modelname ? >>>> it should be "Country" right ? :) >>>> >>>> $this->Countries->country_id = $id; //this is wrong >>>> here should be ALWAYS "id", so $this->Countries->id = $id; >>>> >>>> but u should use camelized and singularized name, so $this->Country->id >>>> = $id and it will work >>>> >>>> >>>> >>>> VIEW: >>>> Form::create(); here you should have the same model name as you pass >>>> data, "Country" and not CountryFrm >>>> -- >>>> Lep pozdrav, Tilen Majerle >>>> http://majerle.eu >>>> >>>> >>>> >>>> 2012/2/23 reynie...@gmail.com >>>> >>>>> Hi every: >>>>> Take a look at this function: >>>>> >>>>> public function edit($id = null) { >>>>> $this->Countries->country_id = $id; >>>>> if ($this->request->is('get')) { >>>>> $this->request->data = $this->Countries->read(); >>>>> } else { >>>>> if ($this->Countries->save($this->request->data)) { >>>>> $this->Session->setFlash(__('The country has been updated.')); >>>>> $this->redirect(array('action' => 'index')); >>>>> } else { >>>>> $this->Session->setFlash(__('Unable to update the country.')); >>>>> } >>>>> } >>>>> } >>>>> >>>>> Aparently all seems to be fine but surprise when I call edit method >>>>> and pass a ID as parameter the data isn't showed in the template, why? Any >>>>> help? This is the edit.ctp content: >>>>> >>>>> Edit Country >>>>&
Re: Why data isn't showed?
So because CakePHP doesn't support compsite PK then the solution need to be change the field country_id for id and also in all the tables. Reading the conventions for Models I get one doubt and goes to oneToMany relations. If I have one relation oneToMany between tables candidate and education and I add the FK candidate_id in education table then CakePHP knows the relation by default? This is correct? Please can you take a look at my DB design and tell me if something is wrong there: http://www.dropmocks.com/mBgrQq ? Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 7:40 AM, Tilen Majerle wrote: > http://book.cakephp.org/2.0/en/getting-started/cakephp-conventions.html > > look here, cakephp conventions > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/2/23 reynie...@gmail.com > >> Hi Tilen, I not understand your point here. As you said I have country_id >> as PK and my table is Countries not Country so my model code is this one >> (Countries.php): >> >> class Countries extends AppModel { >> public $name = 'Countries'; >> } >> >> then if I use $this->Country->id = $id doesn't work and if I >> use $this->Countries->country_id = $id doesn't work too. Which should be >> the solution? Change my table structure or what? >> >> Ing. Reynier Pérez Mira >> http://reynierpm.site90.com/ >> >> >> >> On Thu, Feb 23, 2012 at 5:02 AM, Tilen Majerle >> wrote: >> >>> you have "country_id" as your primary key in table ? >>> >>> and "Countries" for modelname ? >>> it should be "Country" right ? :) >>> >>> $this->Countries->country_id = $id; //this is wrong >>> here should be ALWAYS "id", so $this->Countries->id = $id; >>> >>> but u should use camelized and singularized name, so $this->Country->id >>> = $id and it will work >>> >>> >>> >>> VIEW: >>> Form::create(); here you should have the same model name as you pass >>> data, "Country" and not CountryFrm >>> -- >>> Lep pozdrav, Tilen Majerle >>> http://majerle.eu >>> >>> >>> >>> 2012/2/23 reynie...@gmail.com >>> >>>> Hi every: >>>> Take a look at this function: >>>> >>>> public function edit($id = null) { >>>> $this->Countries->country_id = $id; >>>> if ($this->request->is('get')) { >>>> $this->request->data = $this->Countries->read(); >>>> } else { >>>> if ($this->Countries->save($this->request->data)) { >>>> $this->Session->setFlash(__('The country has been updated.')); >>>> $this->redirect(array('action' => 'index')); >>>> } else { >>>> $this->Session->setFlash(__('Unable to update the country.')); >>>> } >>>> } >>>> } >>>> >>>> Aparently all seems to be fine but surprise when I call edit method and >>>> pass a ID as parameter the data isn't showed in the template, why? Any >>>> help? This is the edit.ctp content: >>>> >>>> Edit Country >>>> >>> echo $this->Form->create('CountryFrm', array('action' => 'edit')); >>>> echo $this->Form->input('country_name'); >>>> echo $this->Form->input('iso_code_2'); >>>> echo $this->Form->input('iso_code_3'); >>>> echo $this->Form->input('country_id', array('type' => 'hidden')); >>>> echo $this->Form->end('Save!!!'); >>>> >>>> >>>> Ing. Reynier Pérez Mira >>>> http://reynierpm.site90.com/ >>>> >>>> -- >>>> Our newest site for the community: CakePHP Video Tutorials >>>> http://tv.cakephp.org >>>> Check out the new CakePHP Questions site http://ask.cakephp.org and >>>> help others with their CakePHP related questions. >>>> >>>> >>>> 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 >>>> >>> >>> -- >>> Our newest site for the community: CakePHP Video Tutorials >>>
Re: Why data isn't showed?
Hi Tilen, I not understand your point here. As you said I have country_id as PK and my table is Countries not Country so my model code is this one (Countries.php): class Countries extends AppModel { public $name = 'Countries'; } then if I use $this->Country->id = $id doesn't work and if I use $this->Countries->country_id = $id doesn't work too. Which should be the solution? Change my table structure or what? Ing. Reynier Pérez Mira http://reynierpm.site90.com/ On Thu, Feb 23, 2012 at 5:02 AM, Tilen Majerle wrote: > you have "country_id" as your primary key in table ? > > and "Countries" for modelname ? > it should be "Country" right ? :) > > $this->Countries->country_id = $id; //this is wrong > here should be ALWAYS "id", so $this->Countries->id = $id; > > but u should use camelized and singularized name, so $this->Country->id = > $id and it will work > > > > VIEW: > Form::create(); here you should have the same model name as you pass data, > "Country" and not CountryFrm > -- > Lep pozdrav, Tilen Majerle > http://majerle.eu > > > > 2012/2/23 reynie...@gmail.com > >> Hi every: >> Take a look at this function: >> >> public function edit($id = null) { >> $this->Countries->country_id = $id; >> if ($this->request->is('get')) { >> $this->request->data = $this->Countries->read(); >> } else { >> if ($this->Countries->save($this->request->data)) { >> $this->Session->setFlash(__('The country has been updated.')); >> $this->redirect(array('action' => 'index')); >> } else { >> $this->Session->setFlash(__('Unable to update the country.')); >> } >> } >> } >> >> Aparently all seems to be fine but surprise when I call edit method and >> pass a ID as parameter the data isn't showed in the template, why? Any >> help? This is the edit.ctp content: >> >> Edit Country >> > echo $this->Form->create('CountryFrm', array('action' => 'edit')); >> echo $this->Form->input('country_name'); >> echo $this->Form->input('iso_code_2'); >> echo $this->Form->input('iso_code_3'); >> echo $this->Form->input('country_id', array('type' => 'hidden')); >> echo $this->Form->end('Save!!!'); >> >> >> Ing. Reynier Pérez Mira >> http://reynierpm.site90.com/ >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> 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 >> > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Using $content_for_layout how :-(
Hi every, I'm newbie using CakePHP and have several doubts and here I come with two of them. I'm trying to use Twitter Bootstrap to build my application Layout, now: - I've created the file View/Layouts/default.ctp and inside in the code I need to use $content_for_layout ($this->fetch it's only available from release 2.1.x and I'm working with 2.0.5) to fetch Bootstrap files, how? - Twitter Bootstrap comes with several files which I put inside app/webroot and of course in the right folder, how I can use this files in default.ctp? Regards, and thanks in advance Ing. Reynier Pérez Mira http://reynierpm.site90.com/ -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
What you mean with debug the save function? This debug($this->Modalidad->save()); or you mean using a IDE like Netbeans? Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Sun, Oct 2, 2011 at 5:31 PM, AD7six wrote: > > > On Oct 2, 10:46 pm, "reynie...@gmail.com" wrote: > > I don't use any behavior and the table has just two fields :-( > > why dont you debug the save function. > > AD > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
I don't use any behavior and the table has just two fields :-( On Oct 2, 2011 2:50 PM, "Zaky Katalan-Ezra" wrote: > Try to leave only one field to save then add fields one by one to get the > problematic field. > Do you use any behaviors with this model? if you do remove them and try to > save. > > > On Sun, Oct 2, 2011 at 6:14 PM, CrotchFrog wrote: > >> Just wondering if this issue has been resolved? I'm having the same >> problem with 2.0 RC2. >> >> On Sep 30, 4:46 am, "reynie...@gmail.com" wrote: >> > Return "Entro" so it goes trough (!empty($this->data)) :-( >> > >> > Ing. Reynier Pérez Mira >> > Cel: +58 416.921.7406 >> > Correo: reynie...@gmail.com / reynie...@hotmail.com >> > >> > On Fri, Sep 30, 2011 at 4:10 AM, Jeremy Burns | Class Outfit < >> > >> > >> > >> > >> > >> > >> > >> > jeremybu...@classoutfit.com> wrote: >> > > Try this: >> > >> > > if (!empty($this->data)) { >> > > $this->Modalidad->create(); >> > > if ($this->Modalidad->save($this->data)) { >> > > die("Entro"); >> > > } else { >> > > $this->Session->setFlash('Ocurrieron errores salvando los datos', >> > > 'default', array('class' => 'example_class')); >> > > die(debug($this->Modalidad->validationErrors)); >> > > } >> > > /* you don't need to use $this->render(), so get rid of it >> > > } else { >> > > $this->render(); >> > > */ >> > > } >> > >> > > Jeremy Burns >> > > Class Outfit >> > >> > > Tel: +44 (0) 208 123 3822 >> > > Mob: +44 (0) 7973 481949 >> > > Skype: jeremy_burns >> > >http://www.classoutfit.com >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> 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 >> > > -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. > > > 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
Well I'm using 1.3.12 so I didn't know where it fails On Oct 2, 2011 11:45 AM, "CrotchFrog" wrote: > Just wondering if this issue has been resolved? I'm having the same > problem with 2.0 RC2. > > On Sep 30, 4:46 am, "reynie...@gmail.com" wrote: >> Return "Entro" so it goes trough (!empty($this->data)) :-( >> >> Ing. Reynier Pérez Mira >> Cel: +58 416.921.7406 >> Correo: reynie...@gmail.com / reynie...@hotmail.com >> >> On Fri, Sep 30, 2011 at 4:10 AM, Jeremy Burns | Class Outfit < >> >> >> >> >> >> >> >> jeremybu...@classoutfit.com> wrote: >> > Try this: >> >> > if (!empty($this->data)) { >> > $this->Modalidad->create(); >> > if ($this->Modalidad->save($this->data)) { >> > die("Entro"); >> > } else { >> > $this->Session->setFlash('Ocurrieron errores salvando los datos', >> > 'default', array('class' => 'example_class')); >> > die(debug($this->Modalidad->validationErrors)); >> > } >> > /* you don't need to use $this->render(), so get rid of it >> > } else { >> > $this->render(); >> > */ >> > } >> >> > Jeremy Burns >> > Class Outfit >> >> > Tel: +44 (0) 208 123 3822 >> > Mob: +44 (0) 7973 481949 >> > Skype: jeremy_burns >> >http://www.classoutfit.com > > -- > Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. > > > 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 -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
Return "Entro" so it goes trough (!empty($this->data)) :-( Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Fri, Sep 30, 2011 at 4:10 AM, Jeremy Burns | Class Outfit < jeremybu...@classoutfit.com> wrote: > Try this: > > if (!empty($this->data)) { > $this->Modalidad->create(); > if ($this->Modalidad->save($this->data)) { > die("Entro"); > } else { > $this->Session->setFlash('Ocurrieron errores salvando los datos', > 'default', array('class' => 'example_class')); > die(debug($this->Modalidad->validationErrors)); > } > /* you don't need to use $this->render(), so get rid of it > } else { > $this->render(); > */ > } > > Jeremy Burns > Class Outfit > > Tel: +44 (0) 208 123 3822 > Mob: +44 (0) 7973 481949 > Skype: jeremy_burns > http://www.classoutfit.com > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
Well the DB isn't MySQL it's SQLite3 ;) I debug $this->data and have values and where I need to write debug($this->Modalidad->validationErrors); after create() or after save()? I'm newbie with Cake and I'm trying to learning and thanks all of yours for the help you bring to me Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Thu, Sep 29, 2011 at 12:33 PM, Toby G wrote: > I think we'll need some more info... > > I woud suggest inspecting your validation erros to see if that's > preventing the records from being saved. > > debug( $this->Modalidad->validationErrors ); > > If you enable debugging, can you see any insert comments in the MySQL > debugging info? > > > > On Sep 29, 3:53 pm, "reynie...@gmail.com" wrote: > > Hi, > > I have a BIG problem because as the title says I can find() but can't > save() > > and not understand where the problem is. This the code: > http://pastebin.com/VNYSh5j3, can any help me to find where the problem > is? > > > > Cheers and thanks in advance > > Ing. Reynier Pérez Mira > > Cel: +58 416.921.7406 > > Correo: reynie...@gmail.com / reynie...@hotmail.com > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
I wrote the code after $this->Modalidad->save($this->data) and this are the results: debug($this->Modalidad->validationErrors); * Array ( )* debug($this->data);* Array ( [Modalidad] => Array ( [nombre] => sdfsdfsd [descripcion] => fsdfsdfd ) )* So there is data and no errors :-( Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Fri, Sep 30, 2011 at 4:02 AM, reynie...@gmail.com wrote: > Well the DB isn't MySQL it's SQLite3 ;) I debug $this->data and have values > and where I need to write debug($this->Modalidad->validationErrors); after > create() or after save()? I'm newbie with Cake and I'm trying to learning > and thanks all of yours for the help you bring to me > > > Ing. Reynier Pérez Mira > Cel: +58 416.921.7406 > Correo: reynie...@gmail.com / reynie...@hotmail.com > > > > On Thu, Sep 29, 2011 at 12:33 PM, Toby G wrote: > >> I think we'll need some more info... >> >> I woud suggest inspecting your validation erros to see if that's >> preventing the records from being saved. >> >> debug( $this->Modalidad->validationErrors ); >> >> If you enable debugging, can you see any insert comments in the MySQL >> debugging info? >> >> >> >> On Sep 29, 3:53 pm, "reynie...@gmail.com" wrote: >> > Hi, >> > I have a BIG problem because as the title says I can find() but can't >> save() >> > and not understand where the problem is. This the code: >> http://pastebin.com/VNYSh5j3, can any help me to find where the problem >> is? >> > >> > Cheers and thanks in advance >> > Ing. Reynier Pérez Mira >> > Cel: +58 416.921.7406 >> > Correo: reynie...@gmail.com / reynie...@hotmail.com >> >> -- >> Our newest site for the community: CakePHP Video Tutorials >> http://tv.cakephp.org >> Check out the new CakePHP Questions site http://ask.cakephp.org and help >> others with their CakePHP related questions. >> >> >> 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 >> > > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
Didn't work either and not, I not change the structure of the table or database :-( Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Fri, Sep 30, 2011 at 2:52 AM, abhimanyu bv wrote: > check this: > http://pastebin.com/MKT4RVkK > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Re: I can find() but can't save(), why?
You mean this: http://pastebin.com/6UsGga4k, didn't work either but it die "Entro" ,what I'm doing wrong? Need the SQLite3 DB specials permissions? I'm in Win7 x64 with XAMPP. Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com On Fri, Sep 30, 2011 at 12:06 AM, abhimanyu bv wrote: > add this line before save, $this->Modalidad->create(); > > Check whether its working or not? > > -- > Our newest site for the community: CakePHP Video Tutorials > http://tv.cakephp.org > Check out the new CakePHP Questions site http://ask.cakephp.org and help > others with their CakePHP related questions. > > > 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 > -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
I can find() but can't save(), why?
Hi, I have a BIG problem because as the title says I can find() but can't save() and not understand where the problem is. This the code: http://pastebin.com/VNYSh5j3, can any help me to find where the problem is? Cheers and thanks in advance Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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
Error while trying to connect to SQLite3 database
Hi every: Recently I migrate an application from one server to another and now when I try to access to the app I get this error: "Fatal error: Call to a member function query() on a non-object in /var/www/reynierpm/magno-reynierpm/models/datasources/dbo/dbo_sqlite3.php on line 144" can any tell me why or where it fails? Cheers and thx in advance Ing. Reynier Pérez Mira Cel: +58 416.921.7406 Correo: reynie...@gmail.com / reynie...@hotmail.com -- Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions. 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