Exemple #1
0
 /**
  * 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->_customerAccountService->canModify($customerData->getId())) {
         return array();
     }
     // Prepare customer confirmation control (only for existing customers)
     $confirmationStatus = $this->_customerAccountService->getConfirmationStatus($customerData->getId());
     $confirmationKey = $customerData->getConfirmation();
     if ($confirmationStatus != CustomerAccountServiceInterface::ACCOUNT_CONFIRMED) {
         $confirmationAttr = $this->_customerMetadataService->getCustomerAttributeMetadata('confirmation');
         if (!$confirmationKey) {
             $confirmationKey = $this->_getRandomConfirmationKey();
         }
         $element = $fieldset->addField('confirmation', 'select', array('name' => 'confirmation', 'label' => __($confirmationAttr->getFrontendLabel())));
         $element->setEntityAttribute($confirmationAttr);
         $element->setValues(array('' => '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', array('name' => 'sendemail', 'label' => __('Send Welcome Email after Confirmation')));
             return array('sendemail' => '1');
         }
     }
     return array();
 }
Exemple #2
0
 /**
  * Prepare the layout.
  *
  * @return $this
  */
 protected function _prepareLayout()
 {
     $customerId = $this->getCustomerId();
     if (!$customerId || $this->_customerAccountService->canModify($customerId)) {
         $this->buttonList->add('save_and_continue', array('label' => __('Save and Continue Edit'), 'class' => 'save', 'data_attribute' => array('mage-init' => array('button' => array('event' => 'saveAndContinueEdit', 'target' => '#edit_form')))), 10);
     }
     return parent::_prepareLayout();
 }
Exemple #3
0
 /**
  * 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->_customerAccountService->canModify($customerId);
     } catch (NoSuchEntityException $e) {
         return false;
     }
 }
Exemple #4
0
 /**
  * Initialize the form.
  *
  * @return $this
  */
 public function initForm()
 {
     /**@var \Magento\Framework\Data\Form $form */
     $form = $this->_formFactory->create();
     $form->setHtmlIdPrefix('_newsletter');
     $customerId = $this->_coreRegistry->registry(RegistryConstants::CURRENT_CUSTOMER_ID);
     $subscriber = $this->_subscriberFactory->create()->loadByCustomerId($customerId);
     $this->_coreRegistry->register('subscriber', $subscriber);
     $fieldset = $form->addFieldset('base_fieldset', array('legend' => __('Newsletter Information')));
     $fieldset->addField('subscription', 'checkbox', array('label' => __('Subscribed to Newsletter'), 'name' => 'subscription'));
     if (!$this->_customerAccountService->canModify($customerId)) {
         $form->getElement('subscription')->setReadonly(true, true);
     }
     $form->getElement('subscription')->setIsChecked($subscriber->isSubscribed());
     $changedDate = $this->getStatusChangedDate();
     if ($changedDate) {
         $fieldset->addField('change_status_date', 'label', array('label' => $subscriber->isSubscribed() ? __('Last Date Subscribed') : __('Last Date Unsubscribed'), 'value' => $changedDate, 'bold' => true));
     }
     $this->setForm($form);
     return $this;
 }