Cakephp 3.6.14:如果表单不完整并且用户离开页面,则会显示确认消息

时间:2019-02-11 14:42:48

标签: javascript php jquery cakephp cakephp-3.x

我正在使用cakephp-3.6.14,并且具有以下格式:

<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>

是否可以显示一条确认消息,例如“您确定要离开此页面吗?”如果用户已经开始填写表格,并且意外地(通过单击菜单项)重定向到另一个页面?

我希望仅在用户已完成表单的至少一个字段时显示确认消息。 question

中未回答的问题

1 个答案:

答案 0 :(得分:0)

我最终使用了这个are-you-sure_plugin