Subfields #613
-
I've this fields with subfields:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
From your code it seems to me that the fields should not be dynamic, so you can just define them inside an array with a condition and then send this array of subfields to the main field like
If I did not understand you correctly and you need subfields to dynamically show/hide other subfields from the same form, then you can refer to https://backpackforlaravel.com/docs/6.x/crud-fields-javascript-api#1-show-hide-a-field and https://backpackforlaravel.com/docs/6.x/crud-fields-javascript-api#11-when-a-repeatable-subfield-changes-disable-another-subfield |
Beta Was this translation helpful? Give feedback.
-
Hot tip for everyone here @blondie63 & @o15a3d4l11s2 ... if you tell Markdown the code syntax, it will use syntax highlighting, so it'll be easier to read. Take a look at this:
vs this: if ($this->data['functionalities']['includeQuantity'] == true) {
$contractDetailsSubfields[] = [
'name' => 'quantity',
'label' => trans('backpack::base.quantity'),
'type' => 'number',
'wrapper' => [
'class' => 'form-group col-md-3',
],
];
} Looks better right? And it was easy to achieve: Hope it helps! |
Beta Was this translation helpful? Give feedback.
Yes, if the subfields should change dynamically based on the admin input, then follow https://backpackforlaravel.com/docs/6.x/crud-fields-javascript-api#11-when-a-repeatable-subfield-changes-disable-another-subfield
As an example: