在编辑模式下打开页面时如何填充 state/region/subregion 个选项?
How to fill state/region/subregion selections when page is opened in edit mode?
在Laravel 8/livewire 2/aplinejs中我需要填写state/region/subregion,这是db中的表
我 select 来自先前 selected 区域的子区域和来自先前 selected 的 select 区域,例如
public function updatedSelectedState($state_id)
{
$this->regionsSelectionArray = Region::getRegionsSelectionArray($state_id, 'A');
$this->detailsForm['state_id'] = $state_id;
}
public function updatedSelectedRegion($region_id)
{
$this->subregionsSelectionArray = Subregion::getSubregionsSelectionByRegionIdArray($region_id);
$this->selectedSubregion = null;
}
插入数据没问题,但是当我在“编辑”模式下打开编辑器时,我需要填写初始值我
失败了怎么办。我记得当我用 jquery 做类似的任务时,我有一个 common bool var,我设置为 true
当 jquery 被启动时。在 onChange 事件中,我检查了这个 var 。
但是我怎样才能在 livewire 中做到这一点?
提前致谢!
在您的编辑方法中调用以下函数
示例:
public function updatedSelectedState($state_id)
{
$this->changeSelectedState($state_id);
}
public function updatedSelectedRegion($region_id)
{
$this->changeSelectedRegion($region_id);
}
public function changeSelectedState($state_id){
$this->regionsSelectionArray = Region::getRegionsSelectionArray($state_id, 'A');
$this->detailsForm['state_id'] = $state_id;
}
public function changeSelectedRegion($region_id)
{
$this->subregionsSelectionArray = Subregion::getSubregionsSelectionByRegionIdArray($region_id);
$this->selectedSubregion = null;
}
public function edit(){
// $state_id = provide your state id here
// $region_id = provide your region id here
$this->changeSelectedState($state_id);
$this->changeSelectedRegion($region_id);
}
在Laravel 8/livewire 2/aplinejs中我需要填写state/region/subregion,这是db中的表 我 select 来自先前 selected 区域的子区域和来自先前 selected 的 select 区域,例如
public function updatedSelectedState($state_id)
{
$this->regionsSelectionArray = Region::getRegionsSelectionArray($state_id, 'A');
$this->detailsForm['state_id'] = $state_id;
}
public function updatedSelectedRegion($region_id)
{
$this->subregionsSelectionArray = Subregion::getSubregionsSelectionByRegionIdArray($region_id);
$this->selectedSubregion = null;
}
插入数据没问题,但是当我在“编辑”模式下打开编辑器时,我需要填写初始值我 失败了怎么办。我记得当我用 jquery 做类似的任务时,我有一个 common bool var,我设置为 true 当 jquery 被启动时。在 onChange 事件中,我检查了这个 var 。 但是我怎样才能在 livewire 中做到这一点?
提前致谢!
在您的编辑方法中调用以下函数 示例:
public function updatedSelectedState($state_id)
{
$this->changeSelectedState($state_id);
}
public function updatedSelectedRegion($region_id)
{
$this->changeSelectedRegion($region_id);
}
public function changeSelectedState($state_id){
$this->regionsSelectionArray = Region::getRegionsSelectionArray($state_id, 'A');
$this->detailsForm['state_id'] = $state_id;
}
public function changeSelectedRegion($region_id)
{
$this->subregionsSelectionArray = Subregion::getSubregionsSelectionByRegionIdArray($region_id);
$this->selectedSubregion = null;
}
public function edit(){
// $state_id = provide your state id here
// $region_id = provide your region id here
$this->changeSelectedState($state_id);
$this->changeSelectedRegion($region_id);
}