BladePartial formfield in Block

I created a new custom form field using a BladePartial in a block. However, when saving, the field value is being stored as a separate top-level property in the payload (image_position) instead of being nested inside the content array of the block
1 Reply
Justin
JustinOP4w ago
This is the payload:
{
"title": "test",
"slug": {
"nl": "test-2",
"en": ""
},
"image_position": "bottom-right",
"cmsSaveType": "update",
"published": true,
"public": false,
"publish_start_date": null,
"publish_end_date": null,
"languages": [
{
"shortlabel": "NL",
"label": "Nederlands",
"value": "nl",
"disabled": false,
"published": true
}
],
"parent_id": 0,
"medias": {},
"browsers": {},
"blocks": [
{
"id": 53,
"type": "a17-block-app-paragraphimage",
"is_repeater": false,
"editor_name": "default",
"content": {
"body": "<p>Lorem ipsum dolor sit amet...</p>",
"theme": null,
"media_type": "image",
"object_fit": "img-fit-cover",
"text_align": "text-left",
"image_width": "img-width-full",
"image_border": null,
"image_height": "img-height-auto"
},
"browsers": {},
"blocks": {}
}
],
"repeaters": {}
}
{
"title": "test",
"slug": {
"nl": "test-2",
"en": ""
},
"image_position": "bottom-right",
"cmsSaveType": "update",
"published": true,
"public": false,
"publish_start_date": null,
"publish_end_date": null,
"languages": [
{
"shortlabel": "NL",
"label": "Nederlands",
"value": "nl",
"disabled": false,
"published": true
}
],
"parent_id": 0,
"medias": {},
"browsers": {},
"blocks": [
{
"id": 53,
"type": "a17-block-app-paragraphimage",
"is_repeater": false,
"editor_name": "default",
"content": {
"body": "<p>Lorem ipsum dolor sit amet...</p>",
"theme": null,
"media_type": "image",
"object_fit": "img-fit-cover",
"text_align": "text-left",
"image_width": "img-width-full",
"image_border": null,
"image_height": "img-height-auto"
},
"browsers": {},
"blocks": {}
}
],
"repeaters": {}
}
And I just followed the guide on the site, nothing special I suppose the only real difference would be this; I'm using it in the getForm
public function getForm(): Form
{
return Form::make([
...
BladePartial::make()
->view('twill.GridSelection')
->withAdditionalParams([
'label' => 'Image position',
'name' => 'image_position',
'options' => [
['value' => 'top-left', 'label' => '↖'],
['value' => 'top', 'label' => '↑'],
['value' => 'top-right', 'label' => '↗'],
['value' => 'left', 'label' => '←'],
['value' => 'center', 'label' => '•'],
['value' => 'right', 'label' => '→'],
['value' => 'bottom-left', 'label' => '↙'],
['value' => 'bottom', 'label' => '↓'],
['value' => 'bottom-right', 'label' => '↘'],
],
]),
public function getForm(): Form
{
return Form::make([
...
BladePartial::make()
->view('twill.GridSelection')
->withAdditionalParams([
'label' => 'Image position',
'name' => 'image_position',
'options' => [
['value' => 'top-left', 'label' => '↖'],
['value' => 'top', 'label' => '↑'],
['value' => 'top-right', 'label' => '↗'],
['value' => 'left', 'label' => '←'],
['value' => 'center', 'label' => '•'],
['value' => 'right', 'label' => '→'],
['value' => 'bottom-left', 'label' => '↙'],
['value' => 'bottom', 'label' => '↓'],
['value' => 'bottom-right', 'label' => '↘'],
],
]),

Did you find this page helpful?