What I’m trying to do:
I’m trying to make a Layout Form that is based on an HTML Template (The standard one I have, the hammered one from @socint). When I’m making the Layout Form, I can use the HTML Slots, but when I apply the Layout to another form, the HTML slots, while still appearing, are useless and I can only drop components into the slots I made with the Designer Layout Functionality.
I would figure that HTML Slots would still work, especially since I want to apply the Layouts as an additional layer of specification on top of the HTML theme I have.
Seems like a bug to me.
Clone link:
share a copy of your app
1 Like
Slot components are added to the layout in the designer. When a Form is using a layout, you can only put components inside the Slot components you added to the layout. Slot components act like portals between the form and its layout. If you don’t have any Slot components then you don’t have any portals.
An anvil-slot is very much like a Slot component. The anvil-slot acts a bit like a portal into the underlying html of the HtmlTemplate. But only once you’ve added the Slot component to the Layout have you created the necessary portal between the Form → the layout → the anvil-slot → to the underlying html of the HtmlTemplate. (slots are not inherited from from the base layout/HtmlTemplate)
In the same way, back in the original layout, you could add a column panel onto the html template, then stick a Slot component on the column panel. Now the Form using the layout has a portal to the layout’s column panel.
Some Edits for clarity and future readers
1 Like
I can understand how they are not the same thing, exact or otherwise, but why is it that it’s either use these new slots or the HTML Slots? Why should it not be possible to use both in the same form?
The purpose I was going to use the new Layouts for was to just add the common components I wanted for a navigation bar and then keep using the HTML Template slots as always when making the forms without adding any of the new slots.
Why should that not be a supported workflow? It seems like unnecessary boilerplate to have to add another layer of new slots to mirror the HTML slots to take advantage of the new functionality.
I guess the short answer is that Slots are not inherited from a parent layout.
If you start nesting more layouts on top of each other, you’ll find that you’ll need to add Slot components into existing Slot components to expose them to the Form using the layout.
That is a use case I hadn’t thought of yet, but seems like somewhat of a problem.
I don’t have a strong opinion on that issue, but the HTML slots one seems like an immediate problem: if anyone has sufficient slots or some existing slots that are still useful, its going to cause extra work and extra problems for a preexisting feature. And it makes it harder to make Layouts from standard HTML pages.
The answer to the question is probably not what you were hoping for,
But I think it’s just that, slots do not get inherited by child layouts.
Because there is no inheritance, yes, it does feel like there’s more boiler plate.
You do need to add a new Slot in order expose the underlying anvil-slot (in the HtmlTemplate case) or Slot (in the parent Layout case) each time you layer a layout on top of another one.
I’m gonna change the category to feature request:
To me it seems like a regression when a feature that is supposed to make designing reusable forms easier (which in a lot of ways it still does), makes extra work in the very area that it’s supposed to make easier – e.g. making us have to add extra and unnecessary abstraction on top of the functioning and preexisting html slots that seems like a bad design choice.
I still like the new layouts and how it makes adding my own slots a lot less tedious and I can now add standard components within it to boot. But it shouldn’t be at the cost of the preexisting slots I could already drop things into
Edit: it seems there’s an error when trying to change it to a feature request, so if someone on the anvil team could do that, that would be much appreciated 
I think better to create a new feature request and link this topic. Now that we’ve had the discussion the feature request will probably be clearer in its scope.
I think the feature request will amount to making it easier to use the underlying slots of a Parent layout, or HtmlTemplate, without having to re-add a Slot component every time they get composed together.
The team did explore inheritance as a way to do layouts, but ultimately decided that composing layouts was a better fit, despite the tradeoffs.
But that’s not to say we can’t improve things to reduce boiler plate.
This is a good point. I suspect that inheritance would have created surprises around event-handlers like the form’s show
handler. The Parent and child may each need their own, distinct handlers for that event.
2 Likes