Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/ant/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在index.php';什么表格?_Php_Database_Yii_Autocomplete_Dropdown - Fatal编程技术网

如何在index.php';什么表格?

如何在index.php';什么表格?,php,database,yii,autocomplete,dropdown,Php,Database,Yii,Autocomplete,Dropdown,我在index.php中实现了搜索功能,该功能正在发挥作用,比如用户输入一些企业名称,并在提交表单后输入一些城市名称,然后从数据库中检索企业。现在,我的下一个任务是使用cguiautocomplete实现表单提交。就像当用户开始键入企业名称时,企业应该在下拉列表中显示出来。我遇到的主要障碍是我在index.php中。我一直在关注这个,但这是一个控制器的视图文件。如何在index.php中实现这一点。下面是我在index.php中的表单 <form action="business/sear

我在index.php中实现了搜索功能,该功能正在发挥作用,比如用户输入一些企业名称,并在提交表单后输入一些城市名称,然后从数据库中检索企业。现在,我的下一个任务是使用
cguiautocomplete
实现表单提交。就像当用户开始键入企业名称时,企业应该在下拉列表中显示出来。我遇到的主要障碍是我在index.php中。我一直在关注这个,但这是一个控制器的视图文件。如何在index.php中实现这一点。下面是我在index.php中的表单

<form action="business/searchingtesting" method="GET">                     
  <div class="form-group form-group-lg">
    <h2 class="title">Find the best places to eat, drink, shop, or visit in Islamabad. </h2>
    <div class="col-sm-5 col-md-5 col-lg-5 col-md-offset-1">
      <input type="text" class="form-control" name="business" id="lg" placeholder="I'm looking for....">
    </div>
    <div class="col-sm-3 col-md-3 col-lg-3">
      <input type="text" class="form-control" id="sm" name="city"  placeholder="Islamabad">
    </div>
    <div class="col-sm-3 col-md-3 col-lg-3">
      <input type="submit" class="btn btn-primary btn-lg" value="submit">
    </div>
  </div>
</form> 

在伊斯兰堡找到最好的吃、喝、买或参观的地方。
如果我按照上面的链接并在表单中使用下面的代码,我会得到这个错误“undefined variable model”


首先。您可以将CJuiAutoComplete like与model一起使用,也可以不使用它。要与模型一起使用,需要指定两个参数:
model
attribute
。如果不使用型号,则仅使用
name
。正如我所看到的,您在表单中没有使用模型,因此下面的示例适用于您:

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name' => 'my_name',
    'sourceUrl' => array('/my/aclist'), // you need first slash if you want properly working URL from web root
));
首先。您可以将CJuiAutoComplete like与model一起使用,也可以不使用它。要与模型一起使用,需要指定两个参数:
model
attribute
。如果不使用型号,则仅使用
name
。正如我所看到的,您在表单中没有使用模型,因此下面的示例适用于您:

$this->widget('zii.widgets.jui.CJuiAutoComplete', array(
    'name' => 'my_name',
    'sourceUrl' => array('/my/aclist'), // you need first slash if you want properly working URL from web root
));

在伊斯兰堡找到最好的吃、喝、买或参观的地方。

在伊斯兰堡找到最好的吃、喝、买或参观的地方。

给该表单一个ID并调用其上的自动完成函数?你是在问我问题还是什么?确保在呈现视图时传递
$model
变量。给该表单一个ID并调用其上的自动完成函数?你是在问我问题还是什么?确保在渲染视图时传递
$model
变量呈现视图亲爱的先生谢谢你的回答,但我是通过另一种方式做到的。亲爱的先生谢谢你的回答,但我是通过另一种方式做到的。
<form action="business/searchname" method="GET">                     
    <div class="form-group form-group-lg">
        <h2 class="title">
            Find the best places to eat, drink, shop, or visit in Islamabad. 
        </h2>
        <div class="col-sm-5 col-md-5 col-lg-5 col-md-offset-1">
        <?php 
        $model = Business::model()->findAll();
        $modelcity = Address::model()->findAll(array(
            'select' => 't.city',
            'group' => 't.city', //selecting distinct values as many businesses hass same cities, so the drop down was filled with only one city
            'distinct' => true,
        ));

        foreach ($model as $mo) {
            $store[] = $mo->business_name;
        }
        foreach ($modelcity as $c) {
            $city[] = $c->city;
        }

        $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
            'name' => 'business',
            'source' => array_values($store),
            // additional javascript options for the autocomplete plugin
            'options' => array(
            'minLength' => '2',
        ),
        'htmlOptions' => array(
            'style' => 'height:45px;width:415px;',
            'placeholder' => '          I am Looking for................ ',
        ),
        ));?>
    </div>
    <div class="col-sm-3 col-md-3 col-lg-3">
        <?php 
        $this->widget('zii.widgets.jui.CJuiAutoComplete', array(
            'name' => 'city',
            'source' => array_values($city),
            // additional javascript options for the autocomplete plugin
            'options' => array(
                'minLength' => '2',
            ),
            'htmlOptions' => array(
                'style' => 'height:45px; width:250px;',
                'placeholder'=>'          City................ ',
            ),
        ));
        ?>
    </div>
    <div class="col-sm-3 col-md-3 col-lg-3">
        <input type="submit" class="btn btn-primary btn-lg" value="submit"/>
    </div>
</div>
</form>