Rendering With Local Variables
You can pass localized arguments to the renderView() and renderLayout() methods in order to encapsulate the rendering via the args struct argument. Much like how you make method calls with arguments. Inside of your layouts and views you will receive the same args struct reference as well.
This gives you great DRYness (yes that is a word) when building new and edit forms or views as you can pass distinct arguments to distinguish them and keep structure intact.

Universal Form

1
<h1>#args.type# User</h1>
2
<form method="post" action="#args.action#">
3
...
4
</form>
Copied!

New Form

1
#renderView(view='forms/universal',args={type='new',action='user.create'})#
Copied!

Edit Form

1
#renderView(view='forms/universal',args={type='edit',action='user.update'})#
Copied!
Last modified 3yr ago
Copy link
Edit on GitHub