/** * @return array */ public function getButtonData() { $customerId = $this->getCustomerId(); $canModify = !$customerId || !$this->customerAccountManagement->isReadonly($this->getCustomerId()); $data = []; if ($canModify) { $data = ['label' => __('Save and Continue Edit'), 'class' => 'save', 'data_attribute' => ['mage-init' => ['button' => ['event' => 'saveAndContinueEdit']]], 'sort_order' => 80]; } return $data; }
/** * @return array */ public function getButtonData() { $customerId = $this->getCustomerId(); $canModify = $customerId && !$this->customerAccountManagement->isReadonly($this->getCustomerId()); $data = []; if ($customerId && $canModify) { $data = ['label' => __('Delete Customer'), 'class' => 'delete', 'id' => 'customer-edit-delete-button', 'data_attribute' => ['url' => $this->getDeleteUrl()], 'on_click' => '', 'sort_order' => 20]; } return $data; }
/** * @return array */ public function getButtonData() { $customerId = $this->getCustomerId(); $canModify = $customerId && !$this->customerAccountManagement->isReadonly($this->getCustomerId()); $data = []; if ($customerId && $canModify) { $data = ['label' => __('Delete Customer'), 'class' => 'delete', 'on_click' => 'deleteConfirm(\'' . __('Are you sure you want to do this?') . '\', \'' . $this->getDeleteUrl() . '\')', 'sort_order' => 20]; } return $data; }
/** * Edit/View Existing Customer form fields * * @param \Magento\Framework\Data\Form\Element\Fieldset $fieldset * @return string[] Values to set on the form */ protected function _addEditCustomerFormFields($fieldset) { $fieldset->getForm()->getElement('created_in')->setDisabled('disabled'); $fieldset->getForm()->getElement('website_id')->setDisabled('disabled'); $customerData = $this->_getCustomerDataObject(); if ($customerData->getId() && $this->_accountManagement->isReadonly($customerData->getId())) { return []; } // Prepare customer confirmation control (only for existing customers) $confirmationStatus = $this->_accountManagement->getConfirmationStatus($customerData->getId()); $confirmationKey = $customerData->getConfirmation(); if ($confirmationStatus != AccountManagementInterface::ACCOUNT_CONFIRMED) { $confirmationAttr = $this->_customerMetadata->getAttributeMetadata('confirmation'); if (!$confirmationKey) { $confirmationKey = $this->_getRandomConfirmationKey(); } $element = $fieldset->addField('confirmation', 'select', ['name' => 'confirmation', 'label' => __($confirmationAttr->getFrontendLabel())]); $element->setEntityAttribute($confirmationAttr); $element->setValues(['' => 'Confirmed', $confirmationKey => 'Not confirmed']); // Prepare send welcome email checkbox if customer is not confirmed // no need to add it, if website ID is empty if ($customerData->getConfirmation() && $customerData->getWebsiteId()) { $fieldset->addField('sendemail', 'checkbox', ['name' => 'sendemail', 'label' => __('Send Welcome Email after Confirmation')]); return ['sendemail' => '1']; } } return []; }
/** * Prepare the layout. * * @return $this */ protected function _prepareLayout() { $customerId = $this->getCustomerId(); if (!$customerId || !$this->customerAccountManagement->isReadonly($customerId)) { $this->buttonList->add('save_and_continue', ['label' => __('Save and Continue Edit'), 'class' => 'save', 'data_attribute' => ['mage-init' => ['button' => ['event' => 'saveAndContinueEdit', 'target' => '#edit_form']]]], 10); } return parent::_prepareLayout(); }
/** * Check block is readonly. * * @return bool */ public function isReadonly() { $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID); if (empty($customerId)) { return false; } try { return $this->_customerAccountManagement->isReadonly($customerId); } catch (NoSuchEntityException $e) { return false; } }