2016-12-05 7 views
0

私はajaxでサインアップしたフォームをレンダリングしました。 ajaxでレンダリングされたブロックをマジェンタで追加した子ブロック2

、フォームをサインアップレンダリング機能です
$block = $resultPage->getLayout() 
      ->createBlock('Magento\Customer\Block\Form\Register') 
      ->setTemplate('Magento_Customer::form/register.phtml') 
      //->toHtml() 
        ; 

次のようしかし、管理者から作成されたこの他の属性で、フォームに表示されません。 だから提出し、追加を表示するために、私は、コードを次のようにコード上で更新されている、

$block = $resultPage->getLayout() 
      ->createBlock('Magento\Customer\Block\Form\Register') 
      ->setTemplate('Magento_CustomerCustomAttributes::/customer/form/register.phtml') 
      //->toHtml() 
        ; 

しかし、まだ属性いずれかが、このことについてどんな考えを持つことができ、表示されないのですか?

答えて

0

問題を解決するには、アップデートハンドルを追加してください。

if ($this->getRequest()->isAjax()) { 
     try { 
      $resultPage=$resultPage->addHandle('customer_form_template_handle'); 
      $block = $resultPage->getLayout() 
      ->createBlock('Magento\Customer\Block\Form\Register') 
      ->setTemplate('Magento_CustomerCustomAttributes::/customer/form/register.phtml') 
      ; 

      $block_attr = $resultPage->getLayout() 
        ->createBlock('Magento\CustomerCustomAttributes\Block\Form') 
        ->setTemplate('Magento_CustomerCustomAttributes::form/userattributes.phtml') 
        ->setFormCode('customer_account_create') 
        ->setEntityModelClass('Magento\Customer\Model\Customer') 
        ; 
      $block->setChild('customer_form_user_attributes',$block_attr); 
      return $this->getResponse()->setBody($block->toHtml()); 
     } catch (\Exception $e) { 
      $response = $e->getMessage(); 
      return $this->getResponse()->setBody($response); 
     } 
    } 
関連する問題