I have a controller that returns route variables to the page:
craft()->urlManager->setRouteVariables(array(
'errors' => $entry->getErrors()
));
On the page that gets loaded, I can access the variables I set in the template:
{% for error in errors %} ...
However, I want to handle this variable dynamically. Is it possible to access the 'errors' variable in my MyPluginVariable.php file without passing it directly to my variable function?
I don't want to do this:
{{ craft.myPlugin.doSomething(errors) }}
That passes my variable to the plugin variable and I can access it just fine. But I don't want to ask the user to pass this variable to the function every time, I'd prefer to just handle it in the background.
So, on the page that gets loaded, instead of outputting the variable, can I have a Twig tag like this:
{{ craft.myPlugin.doSomething() }}
And directly access the 'errors' variable in my plugin? Something like (this doesn't work):
craft()->request->getRouteVariables('errors')
craft.myPlugin.outputForm()
with a single line, so the data I'm getting back is a bunch of stuff that that tag needs to output. When the form is created, the tag just needs to point at the form handle to get all the info it needscraft.myPlugin.outputForm('handle')
but if things don't validate, the page reloads and I have an object of submitted values that need to maintain state and errors and I was just wondering if I could avoid doing something likecraft.myPlugin.outputForm('handle', values, errors)