Controller with multiple functions

I have a controller with two functions. The first sends the form data as email (with the uniform plugin) and the second creates with that info a new page. That works great.

But my problem is, that the second function should only start if the first one ended successfully. So only if all required fields are valid, the page should be created.

I think this should be solved with some basic php code. But I’m not very used to php.

Thanks for your help.

You only need to put your second function within an if-statement, something like:

if($success) {
  //execute 2nd function

life could be so easy… Problem solved!

thank you very much, @texnixe.

That was to early… :wink:
how do i define $success? I have the uniform controller function:

  $form = uniform('contact-form', [
    'required' => [
      'name'  => '',
      '_from' => 'email',
    'actions' => [
        '_action' => 'email',
        'to'      => '',
        'sender'  => '',
        'subject' => 'New message from the contact form'

You can check if an action was successful by using the successful() function:

So that should be something like

if($form->successful()) {
  //do stuff

Awesome… No its working. Thanks a lot for your effort.