更改下拉列表中的输入值
Change input value on change dropdown
在创建部分(新记录)时,当我从下拉列表中 select 酒店房间时,我想将 select 房间的价格输出到另一个输入。
提前致谢!
您将需要使用 dependsOn 字段 属性。
hotel_room:
label: Hotel Room
type: dropdown
price:
label: Price
type: text
dependsOn: hotel_room
现在,只要您 select 来自 hotel_room 下拉列表的值,就会在附加模型上调用以下方法,您可以在其中设置价格字段的值。
public function filterFields($fields, $context = null)
{
if (isset($fields->price)) {
//Write your logic here to get Hotel Price value by hotel id
$hotel_price = 25//For example
$fields->price->value = $hotel_price;
}
}
如果您需要更多帮助,请告诉我?
在创建部分(新记录)时,当我从下拉列表中 select 酒店房间时,我想将 select 房间的价格输出到另一个输入。
提前致谢!
您将需要使用 dependsOn 字段 属性。
hotel_room:
label: Hotel Room
type: dropdown
price:
label: Price
type: text
dependsOn: hotel_room
现在,只要您 select 来自 hotel_room 下拉列表的值,就会在附加模型上调用以下方法,您可以在其中设置价格字段的值。
public function filterFields($fields, $context = null)
{
if (isset($fields->price)) {
//Write your logic here to get Hotel Price value by hotel id
$hotel_price = 25//For example
$fields->price->value = $hotel_price;
}
}
如果您需要更多帮助,请告诉我?