2013-05-07 4 views
0

탭의 CakePHP에서 2 가지 양식을 사용하려고합니다.CakePHP 양식이 데이터를 게시하지 않습니다.

보기에서 'financial_day_begin'작업을 사용하려고합니다.

컨트롤러에는 'financial_day_begin'에서 호출하는 'financial_day'와 'financial_bill_day'의 두 가지 함수가 있습니다.

보기에 대한 코드는 다음, financial_day_begin.ctp : 여기

<div class="panel"> 
    <h2><?php echo sprintf(__("End of Business %s", true), $financial['Financial']['_end_of_business_date']); ?></h2> 
    <div class="panel-content"> 
     <?php echo $this->element('reports/tabs'); ?> 
     <div id="search" class="form"> 
      <?php 
       echo $this->Form->create('Finbill', array('url' => array(
         'controller' => 'reports', 
         'action' => 'financial_day_begin' 
        ))); 
       echo $this->Form->input('end_of_bill_date', array(
        'label' => __("Select Cycle", true), 
        'options' => $finbillList 
       )); 
       echo $this->Form->end(); 
      ?> 
     </div> 
     <?php 
      $labels = array(
       'billed_in_cycle' 
      ); 

      echo $this->Html->tag('h3', __("Billed", true)); 
      echo $this->DataTable->create(array('class' => 'vertical')); 

      foreach($labels as $key => $label) { 
       if(is_numeric($key)) { 
        $key = $label; 
        $label = Inflector::humanize($label); 
       } 

       echo $this->DataTable->createRow(); 
       echo $this->DataTable->createHeader(__($label, true)); 
       echo $this->DataTable->createCell(sprintf("$%s", number_format($finbill['Finbill'][$key], 2)), array('class' => 'value')); 
       echo $this->DataTable->endRow(); 
      } 

      echo $this->DataTable->end(); 

     ?> 
     <div id="search" class="form"> 
      <?php 
       echo $this->Form->create('Financial', array('url' => array(
         'controller' => 'reports', 
         'action' => 'financial_day_begin' 
        ))); 
       echo $this->Form->input('end_of_business_date', array(
        'label' => __("Select Day", true), 
        'options' => $financialList 
       )); 
       echo $this->Form->end(); 
      ?> 
     </div> 
     <?php 
      $labels = array(
       'billed_adjustments' => 'Adjustments' 
      ); 

      echo $this->Html->tag('h3', __("Adjustments", true)); 
      echo $this->DataTable->create(array('class' => 'vertical')); 

      foreach($labels as $key => $label) { 
       if(is_numeric($key)) { 
        $key = $label; 
        $label = Inflector::humanize($label); 
       } 

       echo $this->DataTable->createRow(); 
       echo $this->DataTable->createHeader(__($label, true)); 
       echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value')); 
       echo $this->DataTable->endRow(); 
      } 

      echo $this->DataTable->end(); 

      $labels = array(
       'payments', 
       'payment_reversals', 
       'payments_net' => 'Net Payments' 
      ); 

      echo $this->Html->tag('h3', __("Payments", true)); 
      echo $this->DataTable->create(array('class' => 'vertical')); 

      foreach($labels as $key => $label) { 
       if(is_numeric($key)) { 
        $key = $label; 
        $label = Inflector::humanize($label); 
       } 

       echo $this->DataTable->createRow(); 
       echo $this->DataTable->createHeader(__($label, true)); 
       echo $this->DataTable->createCell(sprintf("$%s", number_format($financial['Financial'][$key], 2)), array('class' => 'value')); 
       echo $this->DataTable->endRow(); 
      } 

      echo $this->DataTable->end(); 
     ?> 
    </div> 
</div> 
<?php 
    $this->Html->script("reports/financial_day", array('inline' => false)); 
?> 

내 컨트롤러, reports_controller.php입니다 : 내가로부터 입력 값을 선택하려고 할 때

<?php 
    class ReportsController extends AppController { 

     var $name = 'Reports'; 
     var $uses = array(
      'Subscriber', 
      'Financial', 
      'Finbill', 
      'Trend' 
     ); 

     var $presetVars = array(
      array(
       'field' => 'posted', 
       'type' => 'value' 
      ), 
      array(
       'field' => 'end_of_business_date', 
       'type' => 'value' 
      ), 
      array(
       'field' => 'end_of_bill_date', 
       'type' => 'value' 
      ), 
      array(
       'field' => 'start_id', 
       'type' => 'value' 
      ), 
      array(
       'field' => 'end_id', 
       'type' => 'value' 
      ), 
      array(
       'field' => 'month_year', 
       'type' => 'value' 
      ) 
     ); 

     function index() { 
      $subscriber = $this->Subscriber->find('first', array(
       'contain' => false, 
       'order' => array('posted' => 'desc') 
      )); 

      $this->set(compact('subscriber')); 
     } 

     function financial_bill_day() { 
      $this->Prg->commonProcess('Finbill'); 

      $searchConditions = $this->Finbill->parseCriteria($this->passedArgs); 

      $finbill = $this->Finbill->find('first', array(
       'conditions' => $searchConditions, 
       'contain' => false, 
       'order' => array('end_of_bill_date' => 'desc') 
      )); 

      $finbillList = $this->Finbill->find('list', array(
       'contain' => false, 
       'fields' => array(
        'end_of_bill_date' 
       ), 
       'order' => array('end_of_bill_date' => 'desc') 
      )); 

      $this->set(compact('finbill', 'finbillList')); 
     } 

     function financial_day() { 
      $this->Prg->commonProcess('Financial'); 

      $searchConditions = $this->Financial->parseCriteria($this->passedArgs); 
      $financial = $this->Financial->find('first', array(
       'conditions' => $searchConditions, 
       'contain' => false, 
       'order' => array('end_of_business_date' => 'desc') 
      )); 

      $financialList = $this->Financial->find('list', array(
       'contain' => false, 
       'fields' => array(
        'end_of_business_date', 
        '_end_of_business_date' 
       ), 
       'order' => array('end_of_business_date' => 'desc') 
      )); 

      $this->set(compact('financial','financialList')); 
     } 

     function financial_day_begin() { 
      $this->financial_day(); 

      $this->financial_bill_day(); 

      $this->set(compact('finbill','finbillList','financial','financialList')); 
     } 

    } 
?> 

문제이며, 내 선택 상자에서 드롭 다운, 아무 것도 (내 브라우저의 주소 표시 줄에 따라) 게시됩니다. 나는 이것이 새로운 가치가 호출되지 않는 이유라고 추측한다.

호출해야하는 동작을 정의해야하는 ctp 파일 외부에 위치가 있습니까?

이 문제에 대한 도움을 주시면 감사하겠습니다.

답변

2

해당 양식은 요청을 제출하지 않고 게시 요청을 제출하므로 데이터가 URL에 포함되지 않습니다. 어떤 데이터가 전송되는지 보려면 컨트롤러 동작 시작시 debug($this->data)을 추가하십시오. $this->passedArgs은 아마도 $this->data으로 대체되어야합니다. 양식을 가져 오기 요청을 사용하려면 다음과 같이 변경해야합니다.

echo $this->Form->create('Finbill', array(
    'url' => array(
     'controller' => 'reports', 
     'action' => 'financial_day_begin' 
    ), 
    'type' => 'get' 
)); 
+0

기본적으로 내 생각에는 동일한 작업을 호출하는 두 가지 양식이 있다고 말하려고합니다. 앱에서 두 번째 양식에서 선택 항목을 변경 한 경우에만 작업 (function financial_day_begin)이 호출됩니다. 첫 번째 양식에서 선택 사항을 변경해도 조치가 호출되지 않습니다. 내가 여기서 뭔가 잘못하고있는거야? 다른 함수 이름으로 시도했지만 첫 번째 양식의 작업은 호출되지 않았습니다. – user2358060

관련 문제