ZeroGodForce
02/25/2022, 1:28 PMparent_id and dynamically loading page options into it - which appears to be working fine. As dynamic options didn't seem to be discussed in the single select documentation, I used the same method described for multi-select and that seems to have worked.
However, when I select a parent page and click to update, the parent_id remains unchanged in the fields array - even though every other field and block is updated. I've verified this by looking at the request data via Telescope, so I'm reasonably sure the updated value is never actually sent to the backend. It retains the value it has when the page originally loads.
If I change the select's name to something else (e.g. "`parent`") and submit this, the example "`parent`" value will be successfully submitted in the fields array - though parent_id is still present and still retains its originally loaded value. My guess is that something is preventing the parent_id value from being updated prior to it being sent out via XHR when the page is updated.
I've been combing through the source trying to find out where this XHR request is generated so I can get a clue why this isn't working correctly but I've run out of ideas. I (even looked at the select field using Vuetools, I can see the value updated on the component in realtime), but my Vue knowledge is a bit limited. Is there something I've missed?ifox
02/25/2022, 1:30 PMifox
02/25/2022, 1:30 PMifox
02/25/2022, 1:32 PMZeroGodForce
02/25/2022, 1:33 PMZeroGodForce
02/25/2022, 1:34 PMifox
02/25/2022, 1:38 PMifox
02/25/2022, 1:38 PMifox
02/25/2022, 1:40 PMZeroGodForce
02/25/2022, 1:44 PMZeroGodForce
02/25/2022, 1:59 PMparents made it appear, however I don't think the format I'm sending the data in is correct. return [
'value' => $key,
'label' => $item
];
and variations thereof doesn't appear to work here. Nor did simply passing a collection of page models. Is there a "correct" format I should be looking for?amargoCactus
02/25/2022, 2:06 PMZeroGodForce
02/25/2022, 2:06 PMkalle
02/25/2022, 2:12 PMlabel & value list.
For select fields enough is to provide
php
protected function formData($request)
{
return [
'parent' => app(PageRepository::class)->listAll(),
];
}
This works well in forms.ZeroGodForce
02/25/2022, 2:14 PMparents keyamargoCactus
02/25/2022, 2:17 PM<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="{{ asset('assets/page/css/styles.css') }}">
<style>
html, body {
height: auto;
}
</style>
</head>
<body
style="
overflow-x: hidden;
margin-top: -1px;
margin-bottom: -1px;
padding-top: 1px;
padding-bottom: 1px;
"
>
@yield('content')
</body>
</html>amargoCactus
02/25/2022, 2:18 PMamargoCactus
02/25/2022, 2:18 PMamargoCactus
02/25/2022, 2:24 PMHarings Rob
02/25/2022, 2:25 PMifox
02/25/2022, 2:28 PMifox
02/25/2022, 2:28 PMZeroGodForce
02/25/2022, 2:32 PM$options = Page::all()->map(function ($item, $key) {
return [
'id' => $item->id,
'name' => $item->title
];
});
it was id and name rather than label and valueZeroGodForce
02/25/2022, 2:33 PMkalle
02/25/2022, 2:37 PMid and name are used.ZeroGodForce
02/25/2022, 2:38 PMAdmin/YourModuleController.php, it's:
php
/**
* Return a list of possible parent pages
*
* @param $request
* @return array
*/
protected function formData($request)
{
$options = Page::all()->map(function ($item, $key) {
return [
'id' => $item->id,
'name' => $item->title
];
});
return [
'parents' => $options
];
}ZeroGodForce
02/25/2022, 2:40 PMkalle
02/25/2022, 2:43 PMamargoCactus
02/25/2022, 2:47 PM