2012-04-06 2 views
0

약 2 개월 전에 SilverStripe 웹 사이트를 2.3.5에서 2.4.6으로 업그레이드했습니다. 업그레이드 이후, 내 사이트의 양식 중 일부는 admin 섹션의 비밀번호 분실 양식과 같은 "시스템"양식을 포함하여 제출 기능에 모든 데이터를 전송하지 않습니다 (POST 항목은 비어 있음). 관리자 로그인 양식의 암호 필드). 이상한 점은 같은 필드를 가진 거의 동일한 (그러나 다른 코드의) 폼을 가지고 있다는 것입니다.이 필드는 잘 작동하지만 필드를 복사해도 작동하지 않습니다. 여기 SilverStripe 양식이 모든 데이터를 전송하지 않습니까?

는 작업 형태이고 그 코드를 제출하기 때문에,

function GenericContactForm() { 

    global $contactmessage; 

    // Create fields 
    $fields = new FieldSet(
      new TextField('NAME', 'Full Name:'), 
      new EmailField('EMAIL', 'Email:'), 
      new TextField('TELEPHONE', 'Work Phone:'), 
      new ListboxField(
       $name = "TYPEOFCONTACT", 
       $title = "Office Type:", 
       $source = array(
       "Single Person Office" => "Single Person Office", 
       "Team Room" => "Team Room", 
       "Open Plan" => "Open Plan" 
       ), 
       $value = 1 
      ), 
        new TextField('HUMAN', '1+1 =') 
    ); 

    // Create actions 
    $actions = new FieldSet(
      new FormAction('doGenericContact', 'Submit') 
    ); 

    return new Form($this, 'GenericContactForm', $fields, $actions); 
} 

function doGenericContact($data, $form) { 
    $human = $data['HUMAN']; 
    if ($human == '2') { 
     $from = $data['EMAIL']; 
     $to = '[email protected]'; 
     $subject = 'Contact Request'; 
     $body = 'The following individual has requested to be contacted: ' . $data['NAME'] . ' | ' . $data['EMAIL'] . ' | ' . $data['TELEPHONE'] . ' and they have made contact to inquire about the following: ' . $data['TYPEOFCONTACT']; 
     $email = new Email($from, $to, $subject, $body); 
     $email->send(); 

     Director::redirect('/thankyou/'); 
    } else { 
     $form->addErrorMessage('Message', "Incorrect answer to the human check. (Your answer: $human)", 'error'); 
     return Director::redirectBack(); 
    } 
} 

나는 ListBoxField에 제거 시도했다 : 여기

function ContactUsForm() { 
     // Create fields 
     $fields = new FieldSet(
         new HeaderField('Send Us a Message:', '2'), 
         new TextField('NAME', 'Full Name:'), 
         new EmailField('EMAIL', 'E-mail Address:'), 
         new TextField('PHONE', 'Phone:'), 
         new TextField('COMPANYNAME', 'Company Name:'), 
         new TextareaField('MESSAGE', 'Message/Note:'), 
         new TextField('HUMAN', '1+1 =') 
     ); 

     // Create actions 
     $actions = new FieldSet(
         new FormAction('doContactUs', 'Submit') 
     ); 

     return new Form($this, 'ContactUsForm', $fields, $actions); 
    } 

    function doContactUs($data, $form) { 

     $human = $data['HUMAN']; 
     if ($human == '2') { 
      $from = '[email protected]'; 
      $to = '[email protected]'; 
      $subject = 'General Contact Submission'; 
      $body = $data['NAME'] . ' has submitted a General Inquiry, their info: ' . $data['NAME'] . ' | ' . $data['EMAIL'] . ' | ' . $data['PHONE'] . ' | ' . $data['COMPANYNAME'] . ' and they have included the following note (if they included a note): ' . $data['MESSAGE']; 
      $email = new Email($from, $to, $subject, $body); 
      $email->send(); 


      Director::redirect('thankyou/'); 
     } else { 
      $form->addErrorMessage('Message', 'Incorrect answer to the human check.','error'); 
      return Director::redirectBack(); 
     } 
    } 

이 작동하지 않는 형태이고, 그 코드가 제출 그것이 내가 발견 한 유일한 차이점입니다. 또한 submit 함수의 if 문에서 "true"부분의 모든 부분을 제거하여 로컬 테스트를 시도했지만 로컬에서는 작동하지만 서버에서는 작동하지 않으므로 SilverStripe와 서버 설정 (서버에 대한 액세스가 제한됨). 또한 이러한 양식은 업그레이드 전에 작동했습니다.

이 문제의 원인에 대한 아이디어와 해결 방법은 무엇입니까?

편집 - 추가 문제 해결은 작동하지 않는 양식의 게시판 배열에 데이터가 없음을 발견했습니다.

+0

"내 사이트의 일부 양식이 모든 데이터를 전송하지 않습니다."라고 말합니다. 실제 문제가 무엇인지 명확히하십시오. 양식이 전자 메일을 보내지 않고 있거나 전자 메일을 보내고 있지만 필드 데이터가 누락되어 있습니까? – ryanwachtl

+0

@ryanwachtl - 인간 수표를 통과하지 못하기 때문에 전자 메일 코드로 보내지도 않습니다. "인간"POST 변수가 비어 있습니다. – Shauna

+0

코드에서 양식이 작동하지 않는 것을 볼 수 없습니다. 'doGenericContact()'내부에서'Debug :: show ($ data)'를 사용하여 폼으로부터 무엇이 제출되고 있는지 살펴보십시오. '$ data [ 'HUMAN']'이 값을 가지고 있는지 확인한 후에, 당신의 이메일 서버가 당신 자신의 도메인이 아닌 다른 도메인으로부터 들어오는 것으로 이메일을 보낼 것인지를 확인하십시오. 문제는 서버 전자 메일 설정과 관련이 있으며 SilverStripe와 관련된 것이 아닙니다. – ryanwachtl

답변

0

SilverStripe 2.4가 모듈을 처리하는 방식과 모듈이 모듈을 처리하는 방식의 문제가 밝혀졌습니다. 나는 그것을 해결 한 사람이 아니었기 때문에 문제에 대한 세부 사항을 알지 못했지만 모듈 2.4가 기대하는 것과 일치하게 모듈을 가져온 것은 해결했습니다.