terminal42 / contao-ajaxform

Submit a form through ajax and display error or confirmation message.
15 stars 7 forks source link

Pass parent content or module model to templates #17

Closed bezin closed 3 years ago

bezin commented 3 years ago

This allows for extending the content or module model with e.g. another text field to accompany the form. You have access to the whole content/module model in the form templates.

Toflar commented 3 years ago

Can't we just do $this->parent? And wouldn't it be helpful to pass that to all of the templates? So underneath where we set $this->tableless = true;, maybe? I cannot really test it right now so I'm asking all these dumb questions :D

bezin commented 3 years ago

Yep, of course that was possible – however not with $this->parent, as this is already a function in the TemplateInheritance trait. So I went with parentModel, which I like better anyways, as it is more precise.

Took me way longer than I would like to admit to spot the early return, but now it is added to all templates 👍