It doesn't matter whether your form comes from an element or a view  
file, it's generating the same HTML in the end, so check that first.
If the form/controller doesn't work it's not a problem of the element.

I'd guess that one of your problems is that you want to redirect as  
the final action of processing the data, but you're already echoing a  
lot of stuff before, so the redirect will fail.

As a side note, you don't need to instantiate Sanitize, you can call  
it statically like Sanitize::clean($data);

On 16 Sep 2008, at 22:11, Daniel wrote:

>
> Hello,
>
>     I currently have a "comment box" view element that I plan to
> embed in various places in my CakePHP application to allow users to
> leave comments on various aspects of the site.
>
>     I'm using the form helper inside of the element to generate the
> form to be used to submit the data, however when I submit the data I
> receive only a blank screen that says "0 query took ms". I've even
> added debugging echoes to the controller to print the data array and
> I'm still just receiving a blank page with "0 query took ms".
>
>     Attached below is the comment "add" method and the respective
> element code.
>
>     Any help anyone can provide would be greatly appreciated, I seem
> to be pretty stuck!
>
>
> Controller code:
>
> function add()
> {
>    echo "XXXXXXXXXXXXXXXXXXXXXXXX";
>    $mrClean = new Sanitize();
>
>    echo "Data ". $this->data;
>
>    if(!empty($this->data))
>       {
>               $mrClean->clean($this->data);
>
>               $currUser = $this->get_current_user();
>               $this->data['Comment']['user_id'] = $currUser['id'];
>               $this->data['Comment']['isDeleted'] = 0;
>
>               $targetEvent = $this->Event->find("first",
>                 array('conditions' => array('Event.id' => 
> $this->data['Comment']
> ['event_id']),
>                               'recursive' => 1));
>
>               print_r($targetEvent);
>
>               if(empty($targetEvent) || is_null($targetEvent))
>               {
>                 $this->Comment->invalidate('event_id', 'You have selected an
> invalid event.');
>                 return;
>               }
>
>               if($this->Comment->save($this->data))
>               {
>                       $this->flash('Your comment has been added',
>                               '/events/view/'. 
> $this->data['Comment']['event_id']);
>               } else {
>                       $this->flash('An error has occured adding your 
> comment.', '/
> events');
>               }
>       }
> }
>
>
> Element code:
>
> <?php echo $form->create('Comment', array('action' => 'add')); ?>
> <table class="commentsTable">
> <tr>
>               <td colspan='99' class='commentSubject'>
>                       Subject: &nbsp;<?php echo $form->input('subject', 
> array( 'label' =>
> false )); ?>
>               </td>
>       </tr>
>       <tr>
>               <td>&nbsp;</td>
>               <td class='commentBody'>
>                       <?php echo $form->textarea('body',
>                               array( 'label' => false,
>                                          'rows' => 7,
>                                          'cols' => 80 )); ?>
>               </td>
>       </tr>
>       <tr>
>               <td colspan='99' class='commentSubmit'>
>                       <?php echo $form->submit('Post Comment'); ?>
>               </td>
>       </tr>
> </table>
> <?php echo $form->hidden('event_id', array('value' => $event_id)); ?>
> <?php echo $form->end(); ?>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to