I have 2 custom table and from admin side I want to save few field values to these 2 custom table while clicking Save button. For example in adminside I have Status option and Message option. The Status option value need to be in custom table 1 and message in custom table 2. How can I do this in Magento 2. I have Save.php file in Controller/Adminhtml/Manage folder.

  • Have you created two models for two tables ? – Murtuza Zabuawala Aug 17 '17 at 12:04
  • Yes I have created 2 models. – Bridgit Thomas Aug 17 '17 at 12:05

Your controller constructor would be like

public function __construct(Action\Context $context,Package\Module\Model\Model1 $model1 , Package\Module\Model\Model2 $model2)
    $this->model1 = $model1;
    $this->model2 = $model2;

public function execute()
    $data = $this->getRequest()->getPostValue(); 

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.