I am writing a plugin which has a controller, service and a model. The model represents some fields which will be POST'd and then emailed via the service.

The controller uses an action to populate the model via the $_POST vars, which is exposed to the template for displaying validation errors:

$fields = BusinessLogic_EventBookingFormModel::populateModel($_POST);

if ($fields->validate()) {
    // send the email...
} else {
        'errors' => $fields->getErrors()

I'd like to expose that model to the template before it's populated, I assume via a template variable. What is standard-practise for instantiating and then managing a reference to that model? Where would the instance live? In the service perhaps?

  • "I'd like to expose that model to the template before it's populated" - I'm confused by that. You want to expose the model to the template before you populate it? – Brad Bell Mar 23 '15 at 19:05
  • Yes. The model is defined but has no data in it. – hamishtaplin Mar 24 '15 at 10:27
  • Where exactly do you want this to happen? From your controller? If so, where in the code? – Brad Bell Mar 24 '15 at 14:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.