1
사용자 정의 블록에 표시해야하는 사용자 정의 등록 양식을 작성하려고하는데 일반 등록 양식을 삽입하고 후크를 통해 변경하거나 form_block과 같은 확장자를 사용하지 않으려 고합니다. Drupal 8이 양식과 함께 작동하는 방법을 배우고 싶습니다.Drupal 8 사용자 정의 등록 양식
내 블록은 다음과 같습니다
내 사용자 등록 양식은 다음과 같습니다<?php
namespace Drupal\ajax_registration_form\Plugin\Block;
use Drupal\ajax_registration_form\Form\AjaxRegistrationForm;
use Drupal\Core\Block\BlockBase;
/**
* Provides a 'AjaxRegistrationBlock' block.
*
* @Block(
* id = "ajax_registration_block",
* admin_label = @Translation("Ajax registration block"),
*)
*/
class AjaxRegistrationBlock extends BlockBase {
/**
* {@inheritdoc}
*/
public function build() {
$content = \Drupal::formBuilder()->getForm(AjaxRegistrationForm::class);
return $content;
}
}
:
<?php
namespace Drupal\ajax_registration_form\Form;
use Drupal\Core\Form\FormStateInterface;
use Drupal\user\RegisterForm;
class AjaxRegistrationForm extends RegisterForm {
/**
* {@inheritdoc}
*/
public function form(array $form, FormStateInterface $form_state) {
return parent::form($form, $form_state);
}
}
난 그냥 일반 RegisterForm
을 확장하려하고 첫 번째 단계에서 그냥 돌아 싶어 부모 양식이 작동하는지 확인하십시오. 하지만 ...하지 않는
오류 메시지 :
Fatal error: Call to a member function getEntityTypeId() on null in /Users/*******/Sites/priv/radweiser/web/core/lib/Drupal/Core/Entity/EntityForm.php on line 77
나는 그것이 형태로 누락 된 사용자 엔티티 생각,하지만 난 내 양식이 실체를 "넣을"수있는 방법을 모른다 .