我有隐藏表单的问题,我的枚举中有driverType数组。如何将字符串从枚举传递给driverform,当我选择PARTTIME时,它会隐藏基本工资表单?
这是我的枚举代码:
dplyr
这是我的DriverController代码:
library(dplyr)
df %>%
group_by(year,type) %>%
summarise(num_serviced = sum(service_type != "Not-serviced"),
num_notserviced = sum(service_type == "Not-serviced"),
num_total = num_serviced + num_notserviced)
# year type num_serviced num_notserviced num_total
# <fctr> <fctr> <int> <int> <int>
#1 2012 AAA 2 0 2
#2 2012 BBB 0 1 1
#3 2013 AAA 1 0 1
这是我的驱动程序表单代码:
<?php
namespace App\Helpers\Enums;
final class DriverType {
const EMPLOYED = 0;
const RENTAL = 1;
public static function getList() {
return [
DriverType::FULLTIME,
DriverType::PARTIME,
];
}
public static function getArray() {
$result = [];
foreach (self::getList() as $arr) {
$result[$arr] = self::getString($arr);
}
return $result;
}
public static function getString($val) {
switch ($val) {
case 0:
return "FULLTIME";
case 1:
return "PARTTIME";
}
}
}
?>
任何想法?
答案 0 :(得分:0)
var select = $('#Type-option');
您已将选择器写入div标签。更改函数上的jQuery应该使用selectbox元素而不是div元素。
Form::select('type', $driverTypeList, 'null', array('class' => 'form-control','id' => 'ID_HERE'));
然后像你这样做你的选择
var select = $('#ID_HERE');
答案 1 :(得分:0)
foreach (self::getList() as $arr) {
$result[$arr] = self::getString($arr);
}
还认为需要将代码替换为
foreach (self::getList() as $arr =>$val) {
$result[$arr] = self::getString($arr);
}
因为我看到你的getString函数应该得到索引。