I’m trying to update a structure field but don’t how what format to pass it to the $page->update() function. My structure field has the following setup:
poptions:
label: Product options
type: structure
style: table
fields:
title:
label: Title
type: text
required: true
quantity:
label: Quantity
type: number
required: true
price:
label: Price
type: number
step: .01
Now I’m getting a new product quantity through a webhook and managed to “find” the right field in the structure but I see no way updating it.
I tried updating the object I get back from ->toStructure(), updating it and passing it back but ->update() doesnt like the value.
return $response->send($html);
}
// Files
if (is_a($input, 'Kirby\Cms\File')) {
return $response->redirect($input->mediaUrl(), 307)->send();
}
// Simple HTML response
if (is_string($input) === true) {
return $response->send($input);
}
// array to json conversion
if (is_array($input) === true) {
return $response->json($input)->send();
}
throw new InvalidArgumentException('Unexpected input');
}
/**
* Renders a single KirbyTag with the given attributes
*
* @internal
* @param string $type
* @param string $value
* @param array $attr
* @param array $data
* @return string
*/
public function kirbytag(string $type, string $value = null, array $attr = [], array $data = []): string
{
$data['kirby'] = $data['kirby'] ?? $this;
$data['site'] = $data['site'] ?? $data['kirby']->site();
$data['parent'] = $data['parent'] ?? $data['site']->page();
return (new KirbyTag($type, $value, $attr, $data, $this->options))->render();
}
Structure field is updated, but I’m getting 500 and can’t do next stuff like show success form message. I’m using Uniform AJAX solution within route in config file.
On mac everything working as expected. Form was sended, emails was sended, success message wa showed and structure field was updated.
On win, form was ended, emails was sended, success message wa showed, but structure field is not updated.
Maybe problem within permissions? I don’t know…
Update:
This is not OS related issue.
Field is updated when I’m logged in.
So it looks like permission problem.
Any suggestion how to update addToStructure function?