0

I am able to add custom tab customer edit section when they click on it i am showing one form by using protected function _prepareForm() { this function form is showing but when i change data in that form after that i click on save and continue data not sending to controller and i am unable to save data any solution how to save data

https://webkul.com/blog/tab-with-form-in-admin-customer-edit-magento-2/

     protected function _prepareForm() {

            if (!$this->canShowTab()) {
                return $this;
            }
            $customer = $this->getCustomer();

    //        $storeScope = \Magento\Store\Model\ScopeInterface::SCOPE_STORES;
    //        echo $this->_scopeConfig->getValue("cms/wysiwyg_config", $storeScope);
    //        print_r($customer->getData());

            /** @var \Magento\Framework\Data\Form $form */
            $form = $this->_formFactory->create();
    //        $form->setHtmlIdPrefix('pawan_');
    //        $form->setFieldNameSuffix('pawan');

            // start connect pro form //
            $fieldset = $form->addFieldset(
                    'base_fieldset', ['legend' => __('CUstome')]
            );

            $fieldset->addField('connectcheck', 'checkbox', array(
                'label' => __(' Enable/Disable'),
                'name' => 'connectcheck',
                'checked' => ($attr == 1) ? true : false,
                'onchange' => "checking()",
                'value' => '1',
                'disabled' => false,
                'after_element_html' => '<small>Active or Deactivate module for frontend</small>',
                'tabindex' => 1,
                'data-form-part' => $this->getData('target_form'),
            ));
$this->setForm($form);

        return parent::_prepareForm();
    }

Getting error on checking() undefined .I tried adding

 $fieldset->setAfterElementHtml('
                                <script>
                                require(["jquery"], function(jQuery) {
                                function checking()
                                    {
                                            alert("hererere");
                                    }
                                    });
                                                                   </script>
                            ');

can any one tell me how to write on change in block

  • Please add your code. – Vinz Jul 9 at 20:46
  • @Vinz I have updated code pls check once if you know pls tell me – Pawankumar Jul 10 at 14:20

Your Answer

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

Browse other questions tagged or ask your own question.