它选择了该选项,但它使数据加倍,使数据加倍。
我尝试过,但没有帮助我。
public class LoginPage : BasePage, ILoad
{
[XPath("//*[@class = 'linkButtonFixedHeader office-signIn']")] private Button SignIn;
[XPath("//input[@type = 'email']")] private TextInputField Email;
[XPath("//input[@type = 'submit']")] private Button Submit;
[XPath("//input[@type = 'password']")] private TextInputField Password;
public LoginPage() : base(new BaseDriver(), "https://outlook.live.com/")
{
}
public bool IsLoaded() =>
SignIn.IsVisible() &&
Email.IsVisible() &&
Submit.IsVisible();
public MainMailPage PositiveLogin(User user)
{
SignIn.Click();
Email.SendString(user.Login);
Submit.Click();
Password.SendString(user.Pass);
Submit.Click();
return Page<MainMailPage>();
}
}
控制器代码
{{ in_array( $rsmsl , $data['state'] ) ?
< option selected value = "{{ $rsms->statesId }}" > {{$rsms->statesName}} </option> :
< option value=" {{ $rsms->statesId }}" > {{ $rsms->statesName }} </option> }}
用于查看数据的刀片模板。
public function editEmp($id){
$task = DB::table('user')
->where('user.userId', '=', $id)
->select('user.*')
->get()[0];
$states = DB::table('states')
->select('states.*')
->get()
->toArray();
$role = DB::table('roll')
->select('roll.*')
->get();
$sd = DB::table('sddetail')
->select('sddetail.*')
->get();
$avp = DB::table('avpdetail')
->select('avpdetail.*')
->get();
$allData = array("user" => $task, "state" => $states, "role" => $role, "sd" => $sd, "avp" => $avp);
return view('modal.editemp', ['data' => $allData]);
}
答案 0 :(得分:0)
<?php
$rsmex = explode(",",$data['user']->statesId);
?>
@foreach($rsmex as $rsmsl)
@foreach($data['state'] as $rsms)
<option @if ( $rsmsl == $rsms->statesId ) {{"selected"}} @endif value={{$rsms->statesId}}>{{$rsms->statesName}}</option>
@endforeach
@endforeach
我不确定$rsmex
的长度。
但是,如果$rsmex
的长度为2,它将遍历所有$data['state']
两次。然后,您两次获得了这些期权数据。
也许这就是您想要实现的目标?只是要遍历状态,并查看用户是否具有状态ID?
@foreach($data['state'] as $rsms)
<option @if (in_array($rsms->statesId, $rsmex)) {{"selected"}} @endif value={{$rsms->statesId}}>{{$rsms->statesName}}</option>
@endforeach