0

長い間検索していますが、問題の解決策が見つかりません。場合によっては、ビューにいくつかのボタンが統合されており、それらをクリックすると、単一の入力フィールドの更新に影響します。問題は、変数がビューで未定義であるという警告があることです。それらを抑制する理由と方法は理解していますが、これが良い解決策であるかどうかはわかりません。これを解決するより良い方法はありますか?ベストプラクティスとは?

ビューファイルからの私のコードは次のとおりです。

<?php 
echo $this->Form->create('Excel', array('type' => 'file'));
echo $this->Form->file('File');
echo $this->Form->submit('Upload xls File');
echo $this->Form->end();

echo $this->Form->create('Config');
//echo $this->Form->input('Name');
echo $this->Form->input('vlanNumber');
echo $this->Form->input('description', array('value' => $description));

echo $this->Form->input('preSharedKey', array('value' => $preSharedKey));
echo $this->Form->button('generate', array('name'=>'generateButton'));

echo $this->Form->input('customerPeerIp', array('default' => 'id_of_default_val','value' => $cusPeerIp));

生成ボタンは、新しい preSharedKey に影響します。また、csv のアップロードは、他のフィールドの更新に影響を与えました。コントローラーの関連コードは次のとおりです。

    public function inputData() {


    if ($this->request->is('post')) {
        $post_data = $this->request->data;
        if (isset($this->request->data['show'])) {  //Submit Button was clicked
            $this->Session->write('Configuration',$post_data); //Store the input fields in the session
            return $this->redirect(array('action' => 'showPreview'));
        } else if (isset($this->request->data['cancel'])) { // Cancel button was clicked: Go back to index site 
            return $this->redirect(array('action' => 'index')); 
        } else if (isset($this->request->data['generateButton'])) {
            return $this->set('preSharedKey', $this->getRandomString(20)); //Set a Pre Shared Key with 30 signs
        }
        if (!empty($this->data) && is_uploaded_file($this->data['Excel']['File']['tmp_name'])) {
            $this->importData($this->data['Excel']['File']['tmp_name']);
            $excel=new Excel();
            $values=$excel->getParams($this->data['Excel']['File']['tmp_name']);
            $this->set('description',$values['description']);
            $this->set('cusPeerIp',$values['cust_peer']);
            return;
              //this calls the Excel Class function

        }
        //print_r($post_data);
        //echo $post_data['Config']['Name'];
        //echo $this->request['Config']['task_1'];
    }
    $this->set('description','');
    $this->set('cusPeerIp','');
    $this->set('preSharedKey', '');
}

手伝ってくれませんか?

4

0 に答える 0