Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZendFramework] layout, zend_form i walidacja ajaxowa
MitS
post
Post #1





Grupa: Zarejestrowani
Postów: 262
Pomógł: 5
Dołączył: 8.02.2005
Skąd: Olsztyn / Zatorze

Ostrzeżenie: (0%)
-----


Witam wszystkich,


mam ogromny problem z sprawdzaniem ajaxowym formularza.
Ale od początku.

Mam sobie layout:
  1. <title>test</title>
  2. </head>
  3. <body id="home" xml:lang="pl">
  4. <div>
  5. <?php echo $this->action('newsletter', 'Offers'); ?>
  6. </div>
  7. <div>
  8. <?php echo $this->layout()->render(); ?>
  9. </div>
  10. </body>
  11. </html>


ta akcja $this->action('newsletter', 'Offers') odwołuje się do kontrolera Offers i akcji newslleter która zawiera:
  1. public function newsletterAction(){
  2. $form = new Form_Newsletter();
  3. $form->setAction($this->view->url());
  4. if ($this->getRequest()->isXmlHttpRequest() && $this->getRequest()->isPost()){
  5. $response = $form->processAjax($this->getRequest()->getPost());
  6. if($response == 'true'){
  7. $formData = $form->getValues();
  8. // tu jakaś akcja
  9. }else{
  10. echo $this->getResponse()->setHeader('Content-type','application/json')->setBody($response);
  11. }
  12. }
  13. $this->view->newsletterForm = $form;
  14. }



i wywołując tę akcję mam zwrotkę w postaci:
Kod
<html>
<head>
   <title>test</title>
</head>
<body id="home" xml:lang="pl">
    <div>
   {"email":{"isEmpty":"Value is required and can't be empty","stringLengthTooShort":"'' is less than 6 characters long","emailAddressInvalidFormat":"'' is no valid email address in the basic format local-part@hostname"}}


i jest prawie dobrze, prawie gdyż nad zwrotką jsonową mam kod html, moje pytanie brzmi: zwrócić jedynie:
{"email":{"isEmpty":"Value is required and can't be empty","stringLengthTooShort":"'' is less than 6 characters long","emailAddressInvalidFormat":"'' is no valid email address in the basic format local-part@hostname"}}

questionmark.gif?
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 21.08.2025 - 00:29