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 <[email protected]> wrote:
> On Mar 10, 4:10 am, pzero <[email protected]> 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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en