Nobody ???
On Jun 3, 4:58 pm, senser <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I'm trying torendera simple form withAjaxfor sending queries from
> the website. The form is in "static"pagecalled "Contacts.ctp" and
> placed in "/views/pages/".
> So here is the content of thepage:
> ..::code_snippet::..
> <?php
> $niceHead->js('prototype.js');
> $niceHead->js('scriptaculous.js');
> $niceHead->js('new_window.js');
>
> print '<h1>'.__('contacts_h1', true).'</h1>';
> print '<p>'.__('contacts_p1', true).'</p>';
>
> print '<div id="ajax_updater" style="display: none; float: none;
> margin: auto 45%;">';
> print $html->image('ajax_update.gif',
> array('class'=>'center'));
> print '</div>';
>
> $this->render('/queries/send', 'empty');
> ?>
> ..::end_of_code::..
>
> The form I'm rendering is in "/views/queries/send" and the code is:
> ..::code_snippet::..
> <?php
> print $ajax->div('ajax_updater', array('style'=>'display: none; float:
> none; margin: auto 45%;'));
> print $html->image('ajax_update.gif',
> array('class'=>'center'));
> print $ajax->divEnd('ajax_updater');
>
> print $ajax->div('query');
> print $ajax->form(array('action'=>'/queries/send', 'post',
> 'update'=>'query'));
> print $form->input('Query.name', array('type'=>'text',
> 'maxlength'=>50, 'length'=>10, 'label'=>__('Name', true),
>
> 'error'=>array('required'=>__('Validation_required', true),
> 'maxlength'=>__('Validation_length', true))));
> print $form->input('Query.email', array('type'=>'text',
> 'maxlength'=>50, 'length'=>10, 'label'=>__('Email', true),
>
> 'error'=>array('required'=>__('Validation_required', true),
> 'permitted'=>__('Validation_permitted', true),
> 'maxlength'=>__('Validation_length', true))));
> print $form->input('Query.phone', array('type'=>'text',
> 'maxlength'=>50, 'length'=>10, 'label'=>__('Phone', true),
>
> 'error'=>array('permitted'=>__('Validation_permitted', true),
> 'maxlength'=>__('Validation_length', true))));
> print $form->input('Query.text', array('type'=>'textarea',
> 'cols'=>50, 'rows'=>10, 'label'=>__('Text', true),
>
> 'error'=>array('required'=>__('Validation_required', true),
> 'maxlength'=>__('Validation_length', true))));
> print $ajax->submit('Submit', array('url'=>'/queries/send',
> 'update'=>'query', 'indicator'=>'ajax_updater'));
> print $ajax->divEnd('query');
> ?>
> ..::end_of_code::..
>
> As you can see the form is pretty simple - it doesn't run any SQL
> queries, just validate fields and send an email. Controller action
> responsible for email sending and validation is this:
> ..::code_snippet::..
> function send($id=null){
> $this->layout='empty';
>
> if(!empty($this->data['Query'])){
> $this->Query->set($this->data['Query']);
> if($this->Query->validates()){
> if(!empty($id)){
>
> $this->Query->bindModel(array('belongsTo'=>array('Offer')));
> $this->Query->Offer->set('id', $id);
> if($this->Query->Offer->exists()){
>
> $this->data['Query']['about']=$id;
> }
> }
>
> $this->set('Query', $this->data['Query']);
>
> $this->Email->to='[EMAIL PROTECTED]';
>
> $this->Email->replyTo=$this->data['Query']['email'];
>
> $this->Email->from=$this->data['Query']['email'];
> $this->Email->subject='Query from website';
> $this->Email->sendAs='text';
> $this->Email->template='default';
> $this->Email->delivery='smtp';
>
> $this->Email->smtpOptions=array('host'=>'mail.domain.com',
> 'port'=>25, 'timeout'=>15, 'username'=>'[EMAIL PROTECTED]',
> 'password'=>'password');
>
> if($this->Email->send()){var_dump('EMAIL OK');
> //$this->set('success', true);
>
> $this->Session->setFlash(__('Successful_query'));
> }
> else{var_dump('EMAIL PROBLEM');
> $this->render('/queries/send',
> 'empty');
> }
> }
> else{var_dump('DATA INVALID');
> $this->render('/queries/send', 'empty');
> }
> }
> else{var_dump('DATA EMPTY');
> $this->render('send', 'empty');
> }
> }
> ..::end_of_code::..
>
> So the problem is that when I loadpageContacts the form is displayed
> correctly, but when click on Submit button of the form, the progress
> indicator (id="ajax_update") is displayed and the form hides, i.e.
> doesn'trenderwith status messages from controller action.
>
> I added some var_dump() lines in controller for debugging purposes and
> they're shown in Contactspagebut form doesn'trenderactually. For
> example if form doesn't validate, Contactspagereceives "DATA
> INVALID", but form is not displayed.
>
> Am I missing something or may be doing some wrong .........
>
> Thank you for support in advance.
>
> Regards!
>
> P.S. I have development server where this code works fine, but
> doesn'trenderon hosting servers, so may be there's some issue with
> configuration settings may be .........
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---