This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

cydrick.nonog
cydrick.nonog

Hi everyone i created a field.yaml that has repeater. The repeater is working my problem is my repeater when i click the add new it will also include my extend field.

field.yaml

....
informations[contacts]:
      type: repeater
      tab: cyd293.user::lang.models.profile.tabs.contacts
      form:
        fields:
          mobile:
            label: Mobile Number

code for extended

Event::listen('backend.form.extendFields',function($widget, $fields){
            if(($widget->getController() instanceof UserController) && ($widget->model instanceof UserModel)){
                $widget->getController()->initRelation($widget->model);
                AccountModel::getFromUser($widget->model);
                $widget->addFields([
                    'account[sponsor]'=>[
                        'label'=>'homeworkxsolutions.tcf::lang.models.account.sponsor.label',
                        'type' => 'recordfinder',
                        'list' => '$/cyd293/user/models/user/columns.yaml',
                        'nameFrom' => 'id_with_full_name'
                    ],
                ]);
            }
        });

the repeater also included the field account[sponsor]

Last updated

cydrick.nonog
cydrick.nonog

I make some solution for this. But i know this is not the right method for this.

...
informations[contacts]:
      type: repeater
      tab: cyd293.user::lang.models.profile.tabs.contacts
      form:
        include: false --- i include this to be input to config that will be send by the repeater to FormWidget
        fields:
          mobile:
            label: Mobile Number
Event::listen('backend.form.extendFields',function($widget, $fields){
            if(($widget->getController() instanceof UserController) && ($widget->model instanceof UserModel)){
                $widget->getController()->initRelation($widget->model);
                AccountModel::getFromUser($widget->model);
                if($widget->getConfig('include',true)) --- this will check if the form has a config "include"
{ 
                $widget->addFields([
                    'account[sponsor]'=>[
                        'label'=>'homeworkxsolutions.tcf::lang.models.account.sponsor.label',
                        'type' => 'recordfinder',
                        'list' => '$/cyd293/user/models/user/columns.yaml',
                        'nameFrom' => 'id_with_full_name'
                    ],
                ]);
}
            }
        });

Last updated

1-2 of 2

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.