Replies: 2 comments
-
This is not possible out-of-the-box, but you can try to use October's event system to change the form. You can for example always include all options in your yaml config and then use some PHP to hide the fields if a box is not rendered as a child of your grid item. Something along the lines of (untested code): \Event::listen('backend.form.extendFields', function ($widget) {
if (!$widget->getController() instanceof \OFFLINE\Boxes\Controllers\EditorController) {
return;
}
if (!$widget->model instanceof \OFFLINE\Boxes\Models\Box) {
return;
}
$parentBoxId = post('Box.parent_id');
// This is a top-level box, remove unwanted fields...
if (!$parentBoxId) {
// Add your logic to remove fields here.
$widget->removeField(...);
}
}); |
Beta Was this translation helpful? Give feedback.
-
Ok thank you, I will try that. As a suggestion, I think it could be extremly powerful to extend the context option (that allow to make a box available depending on it's parent) on a field level. That would allow to do that kind of thing without extra coding. Best regards, |
Beta Was this translation helpful? Give feedback.
-
Hello,
I wonder if it's possible to have different field definition depending on the parent box when you activate the children mode.
Here is the use case, I want to create boxes to generate row, column or grid. This is structure boxes.
I also have some "basic" boxes : Image, Text, etc....
When a box of type image is in a parent box of type grid, I want to display different options (related to grid) than an image box that is in a parent box of type column.
Is it possible ?
Thank you
Beta Was this translation helpful? Give feedback.
All reactions