javascript - pass PHP variable values to view page in YII -
I'm new to Yii, I want to pass the PHP variable value to my controller to see. Can someone help me on this? I'm stuck here, I should calculate this variable in javascript in the auto-complete field. Thanks in advance.
My Controller Action:
Public Function Action Index () {$ user = Yii :: app () - & gt; Db- & gt; CreateCommand () - & gt; Select ('cust_name') - & gt; From ('mst_customers') - & gt; Query all (); $ Detector = New Citizenship Provider ('Model_Name'); $ This- & gt; Render it ('index', array ('data provider' =>; $ dataspreader,)); } My view:
& lt ;! - content - & gt; & Lt; Div id = "content" & gt; & Lt; Div style = "padding: 10px;" & Gt; & Lt; A href = "& lt ;? php echo $ this- & gt; create url ('/ controller_name / create') ;? & gt;" Title = "create new host" class = "btn btn-primary circle_ok" style = "text-decoration: none;" & Gt; Add a new host to the customer & lt; / A & gt; & Lt; Div style = "float: right" & gt; & Lt ;? Php echo CHtml :: link ('Customer CSV Upload', array ('/ controller_name / upload customer'), array ('onclic' = & gt; 'returns hs_mindap (this, {object type: "iframe", wrapper classname : "Full size", align: "center"}) ',' class' = & gt; 'btn btn-primary', 'id' = & gt; 'upload_link',)); ? & Gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; H3 & gt; & Lt ;? Php htmlspecialchars ($ title); ? & Gt; & Lt; / H3 & gt; & Lt; H3 & gt; & Lt ;? Php echo $ title; ? & Gt; & Lt; / H3 & gt; & Lt; Div class = "innerr r" & gt; & Lt; Div class = "line-fluid" & gt; & Lt ;? Php $ obj = $ this- & gt; Widget ('zii.widgets.grid.CgrridView', array ('data provider' => $ dataprider, // 'afterAjaxUpdate' = & gt; '\' changeTRColor () \ '', '' view '= & gt; ; 'Name', 'value' = & gt; '_view', 'column' = & gt; array (array (// using an expression 'name' 'create_time' => $ Data-> gt; ; 'Name' = & gt; 'serviceId', 'value' = & gt; '$ data- & host_serviceid',), array ('name' = & gt; customer ',' host_name ',), array (' name '=' 'Value' = & gt; '$ data-> customer- & gt; cust_name',), array ('class' = & gt; cbttoncolumn ',' template '= & gt;' {delete} {update } ',)),)); ? & Gt; & Lt; / Div & gt; & Lt; Html lang = "en" & gt; & Lt; Top & gt; & Lt; Meta charset = "UTF-8" & gt; & Lt; Title & gt; JQuery UI auto complete - default functionality & lt; / Title & gt; & Lt; Link rel = "stylesheet" href = "// code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> & Lt; Script src = "// code.jquery.com/jquery-1.9.1.js"></script> & Lt; Script src = "// code.jquery.com/ui/1.10.4/jquery-ui.js"></script> & Lt; Link rel = "stylesheet" href = "/ resources / demos / style.css" & gt; & Lt; Script type = "text / javascript" & gt; // Autocomplete $ (function () {var available tugs = & lt ;? php echo cgsson :: encoded ($ user) ;? & gt;; / * "action script", "apescript", "ap" "Basic", "C ++", "Closer", "Cobol", "Cold Fusion", "Erlang", "Fortran", "Groove", "Haskell", "Java", "Javascript" $ ("#search"), "Lisp", "Perl", "PHP", "Python", "Ruby", "Scala", "Scheme" * / console.log (available tags). Autocomplete ({source: AvailableTags});}); & Lt; / Script & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Div class = "ui-widget" & gt; & Lt; Label = "search" & gt; Search Customer: & lt; / Label & gt; & Lt; Input id = "search" & gt; & Lt; / Div & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; Div class = "separator down" & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt; / Div & gt; & Lt ;! - // content END - & gt; & Lt; Div class = "clearfix" & gt; & Lt; / Div & gt; & Lt ;! - // Sidebar Menu & amp; Content Cover END - & gt; & Lt; Div id = "footer" class = "hidden print" & gt; & Lt ;? Php $ this- & gt; Renderpartial ('application.views.layouts._footer_inc'); ? & Gt; & Lt; / Div & gt;
$ this-> Render ('index', array ('DataProvider' = & gt; $ dataprider, 'user' =>; $ user,));
Comments
Post a Comment