Re: cakephp blog english
Hello Thanks a lot for your quick reply. this is my edit function function edit($id = null) { $actionHeading = 'Post bearbeiten!'; $actionSlogan = 'Bitte alle Felder ausfüllen.'; $this-set(compact('actionHeading','actionSlogan')); if (!$id empty($this-data)) { $this-Session-setFlash(__('Ungültiger Post', true)); $this-redirect(array('action'='index')); } if (!empty($this-data)) { if ($this-Post-save($this-data)) { $this-Session-setFlash(__('Post wurde erfolgreich gespeichert', true)); $this-redirect(array('action'='index')); } else { $this-Session-setFlash(__('Post konnte leider nicht gespeichert werden. Versuche es nochmal.', true)); } } if (empty($this-data)) { $this-data = $this-Post-read(null, $id); } } and this is my validation rules ?php class Post extends AppModel { var $name = 'Post'; var $hasMany = array('Comment'); /*Validierung der Eingaben*/ var $validate = array( 'title'=array( 'alphaNumeric'=array( 'rule'='alphaNumeric', 'required'=true, 'message'='Bitte ein Titel erfassen', ) ), 'content'=array( 'alphaNumeric'=array( 'rule'='alphaNumeric', 'required'=true, 'message'='Bitte Kommentar erfassen', ) ) ); } ? but haven't understood what i have to do for editing a post. thanks a lot for your help with kind regards On 10 Mrz., 18:25, cricket zijn.digi...@gmail.com wrote: On Mar 10, 4:10 am, pzero domenico.gu...@gmail.com wrote: Good Morning together, I created a blog with Cakephp and now I have two issues. If i edit a post instead of updating this post my application create a new post, You need to include a hidden field in the form for the id. echo $form-hidden('Post.id'); Substitute your model name for Post if different. When Cake saves, if the id is present in $data, it will try to update an existing record in DB. and the second issue is by adding a new post. If i write in my title and in my comment box text without blanks it works, but if i write for example title: my test with a blank between my and test i receive the message that i must write a title. You have a validation rule for title that does not allow spaces. Can you post the $validate array for the model? I can't attached my Blog so if someone can help me write me your mail adress so that i can send you my blog. I hope someone can help me. I have to present this blog at saturday in my shool and I have no idea about this two issues No need to send the entire thing. Just post that one part of your model. Also, you could post the edit() method from the controller. 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: cakephp blog english
Hallo cricket, Thanks a lot, the validation rules works. But i don't had understood where i have to include a hidden form input... Sorry im a newbie. On 12 Mrz., 17:40, cricket zijn.digi...@gmail.com wrote: The alphaNumeric rule is equivalent to /[a-A-Z0-9]+/ and is only useful for something like a password or other code. For something like a title, try 'rule' = array('minLength', 1). It's a lot more flexible. For editing a record, you need to include the id in $this-data for the save(). Include a hidden form input with the id so that it is included in $data. 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: cakephp blog english
Hey cricket thanks a lot. i fixed this issue with your help. You are the best :) Now it works i put the hidden field echo $form-hidden('Post.id'); when i edit a post now it updates and it doens't create a new post. i wish you a nice weekend!!! and thanks a lot On 12 Mrz., 18:29, cricket zijn.digi...@gmail.com wrote: On Mar 12, 12:09 pm, pzero domenico.gu...@gmail.com wrote: Hallo cricket, Thanks a lot, the validation rules works. But i don't had understood where i have to include a hidden form input... Sorry im a newbie. That's ok. We all start from somewhere. I'm still confused about a lot of Cake things. You put the hidden field in the view. Just after your $form- create(...) add this: echo $form-hidden('Post.id'); What happens is that $this-data = $this-Post-read(null, $id) will include the id in the result. FormHelper should then find the id in $data inside the view. If it still doesn't seem to be working, set debug to 2 and try this: if (!empty($this-data)) { die(debug($this-data)); That is, right before the call to save(). Make sure that the data array contains an id. You can also view source when you first load the form and ensure that the hidden field is there and that the value is correct. 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
cakephp blog
Hallo zusammen, Ich habe ein Blog mit Cakephp erstellt hab aber zwei Probleme die ich nicht lösen kann. Und zwar erstellt mein Blog beim editieren eines Posts ein neuer Post anstatt dass der post editiert wird. Ein zweites Problem ist wenn ich ein neuer Post erfassen will nur strings ohne leerzeichen angenommen werden. Wenn ich z.b Mein Blog schreibe bekommt ich die meldung dass ein titel erfasst werden soll, irgendwie hat er dann das gefühl es ist kein titel erfasst oder der string ist empty. Wenn mir jemand helfen kann kann ich ihm mein Blog per e-mail schicken sodass es nachvollziehen werden kann. Liebe grüsse 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
cakephp blog english
Good Morning together, I created a blog with Cakephp and now I have two issues. If i edit a post instead of updating this post my application create a new post, and the second issue is by adding a new post. If i write in my title and in my comment box text without blanks it works, but if i write for example title: my test with a blank between my and test i receive the message that i must write a title. I can't attached my Blog so if someone can help me write me your mail adress so that i can send you my blog. I hope someone can help me. I have to present this blog at saturday in my shool and I have no idea about this two issues kind regards 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