php - Set $_GET Using Yii HiddenField Method -


i trying set $_get if button selected. currently, trying set using following command: chtml::hiddenfield('hidden', $displaydata = "option1"); reloads page. suggestions?

controller:

<?php     $data1 = new carraydataprovider(.......){         .......     }      $data2 = new carraydataprovider(.......){         .......     }      if(isset($_get['export'])){         $displaydata = $_get['export'] == 'option1' ? $data1 -> getdata() : $data2 ->getdata();          // export csv file content here      } ?> 

view:

<?php     // button 1     chtml::hiddenfield('hidden', $displaydata = "option1");     // button , other data ?>   <?php     // button 2     chtml::hiddenfield('hidden', $displaydata = "option2");     // button , other data  ?> 

read yii docs hidden field: link

public static string hiddenfield(string $name, string $value='', array $htmloptions=array ( )) 

so code in views should this:

chtml::hiddenfield('export', option1); or chtml::hiddenfield('export', option2); 

also, must understand hiddenfield not button or form, won't send data anywhere. send data user server should use cactiveform hidden field. can find example here


Popular posts from this blog