0

I am using cakephp-3.6.14 and I have this form:

<div class="customers form large-9 medium-8 columns content">
<?= $this->Form->create($customer) ?>
<fieldset>
    <legend><?= __('Edit Customer') ?></legend>
    <?php
        echo $this->Form->control('company');
        echo $this->Form->control('name');
        echo $this->Form->control('surname');
        echo $this->Form->control('tel');
        echo $this->Form->control('mob');
        echo $this->Form->control('email');
        echo $this->Form->control('customer_type_id', ['options' => $customerTypes, 'empty' => true]);
        echo $this->Form->control('business_type_id', ['options' => $businessTypes, 'empty' => true]);
        echo $this->Form->control('business_name');
        echo $this->Form->control('balance');
        echo $this->Form->control('birthday', ['empty' => true]);
        echo $this->Form->control('notes');
        echo $this->Form->control('user_assigned');
        echo $this->Form->control('created_by');
        echo $this->Form->control('created_date', ['empty' => true]);
        echo $this->Form->control('modified_by');
        echo $this->Form->control('modified_date', ['empty' => true]);
        echo $this->Form->control('Address');
    ?>
</fieldset>
<?= $this->Form->button(__('Submit')) ?>
<?= $this->Form->end() ?></br></br>

Is it possible to show a confirmation message like "Are you sure you want to leave this page?" if the user has started completing the form and accidentally (by clicking on a menu item) redirects to another page?

I want the confirmation message to be displayed only if the user has completed at least one field of the form. Which is not answered in this question

aggtr
  • 91
  • 9
  • Possible duplicate of [Intercept page exit event](https://stackoverflow.com/questions/1704533/intercept-page-exit-event) – Cid Feb 11 '19 at 14:46
  • @Cid I want the confirmation message to be displayed only if the user has completed at least one field of the form. Which is not answered in this question you provided as duplicate. – aggtr Feb 11 '19 at 14:57
  • Nothing stops you from checking the values in the inputs in that function – Cid Feb 11 '19 at 15:06

1 Answers1

0

I ended up using this are-you-sure_plugin

aggtr
  • 91
  • 9