KurtJensen
KurtJensen

I have extended the user model and controller with two seperate plugins as user->many relationships. Each plugin adds its own tab to selected user update area of backend. On those tabs, (cellphones and dates) records are listed and clicking a record brings up edit form. Great... everything working so far.

The problem is that the edit form also shows my two added tabs (cellphones and dates) at the bottom of the popup form with records listed. The records listed on both of those tabs are only from the model being edited. For example. .. if the popup form is for editing a cell phone then all cellphone records are listed on both the date and cellphone tabs at the bottom of the popup form above the save annd cancel buttons. Code for cellphone form is:

<?= $this::relationRender('cellphones'); ?>

Code for date form is:

<?= $this::relationRender('dates'); ?>

Is there a way i can suppress tabs in popup form?

KurtJensen
KurtJensen

Resolved issue by modifying Plugin.php. Added an IF statement to check for popup form before adding tabs to form.

    if (!post('_relation_field')){
        UsersController::extendFormFields(function($form, $model, $context){
                $form->addTabFields([
                'cellphones' => [
                    'label' => 'Cell Phone',
                    'tab' => 'Cell Phones',
                    'type' => 'partial',
                    'path' => '@/plugins/iaff106/cellphone/partials/_std_form.htm'
                    ],
                    ]);
            });
    }
sercanvirlan
sercanvirlan

this fixed create dialog but update dialog is messed

KurtJensen
KurtJensen

A few more checks are needed.

if (!post('_relation_field')) {
        UsersController::extendFormFields(function ($form, $model, $context) {

            if (!$model instanceof UserModel) {
                return;
            }

            if (!$model->exists) {
                return;
            }

            if ($form->getContext() != 'update' && $form->getContext() != 'preview') {
                return;
            }

1-4 of 4