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

gliba20174
gliba20174

I created custom button with handler onRelationButtonAddAnonymus, then in my controller i call


public function onRelationButtonAddAnonymus()
    {
        return $this->onRelationManagePivotForm();
    }
public function onRelationManagePivotForm()
    {
        $this->beforeAjax();

        $this->vars['foreignId'] = "1";
        return $this->relationMakePartial('pivot_form');
    }

and i get error method beforeAjax not defined... In RelationController that method is private, when i change to public all working. Im implementing relationController in my main controller class

norotaro
norotaro

Maybe this can work


public function onRelationManagePivotForm()
    {
        $this->asExtension('RelationController')->onRelationManagePivotForm(); // this call will execute $this->beforeAjax internally

        $this->vars['foreignId'] = "1";
        return $this->relationMakePartial('pivot_form');
    }
gliba20174
gliba20174

Yep, but $this->vars['foreignId'] = "1" wont be passed... Wen i run code in my model i get forgen_id = null :( Apparently Ajax func need to be called to $this->vars can bee used, or is ther some other way?

gliba20174
gliba20174

Aha!!! You can pass var as second argument to relationMakePartial method like so

return $this->relationMakePartial('pivot_form', ['foreignId' => "1"]);

norotaro

1-5 of 5

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