English 中文(简体)
在 cakephp 中的下拉列表
原标题:Dropdown List in cakephp

数据库是这样的 业主有很多猫

< 坚固的拥有者 < /坚固的所有人ID 所有人Name

< 加固 > Cat cideID cateType 所有人ID

我试图添加新的猫, 在所有者ID的域内, 我想显示所有所有者姓名的下载列表。 我该怎么做呢?

问题回答

我猜你已经拥有了所有者模型 也就是所有者的下调名单

< 坚固 > 在 Conrtoller < /坚固 >

$Owner = $this->Owner->find( list , array( fields  => array( Owner.ownerID ,  Owner.ownerName )));

$this->set( owners , $owner);

<强> 在视图

<?php echo $form->input( owner , array(
         label  => false,
         id  =>  owner_id ,
         options  => $owners
    )); ?>

在你的公寓里写:

$all_security_question = $this->Security_question->find( list ,array( fields =>array( id , question )));
$this->set("all_security_question",$all_security_question);


   Write in your Model:<?php echo $this->Form->input( security_question_id , array(
                                                 label  => false,
                                                 id  =>  id ,
                                                 options  =>$all_security_question
                                            )); ?>  




相关问题
PHP Combo Box AJAX Refresh

I have a PHP page that currently has 4 years of team positions in columns on the page. The client wants to select the players in positions and have first, second and thrid choices. Currently the page ...

jquery + ajax + json + fill dropdown list not working

I m pretty sure i am almost there....but i cannot figure out how to iterate through json objects and fill a dropdown list. Here is the js code: My JSON data returned:{"name":"County1","name":"County1"...

Gridviews and DropdownLists

Is it possible to change the data source of a dropdown list in a gridview from another dropdown list selected index changed method in the same gridview? for example I have a dropdown that needs to ...

Adding a new value to the drop down list box

I have a drop down list box which has one of the values to be others. I want to move these value to the last. Please help me with this. The code i am using is as follows ddlAssetsCountryOthersone....

Show hide div using codebehind

I have a DropDownList for which I am trying to show a div OnSelectedIndexChanged but it says OBJECT REQUIRED. I am binding the DataList in that div: aspx: <asp:DropDownList runat="server" ID="...

Why might dropdownlist.SelectedIndex = value fail?

I have a dropdown list that I am binding to a datatable. Here is the code I am using to do it: ddlBuildAddr.DataSource = buildings ddlBuildAddr.DataTextField = "buildingName" ddlBuildAddr....

热门标签