I have two fields created at the email section in checkout in magento2. I want to create a customer on order place. I am currently using “sales_order_payment_save_before” to get field data but not getting any data from the field.
I have created two fields in email.html in
app/design/frontend/Vendor/Theme/Magento_Checkout/web/template/form/element/email.html
<!-- ko ifnot: isCustomerLoggedIn() -->
<!-- ko foreach: getRegion('before-login-form') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
<form class="form form-login" data-role="email-with-possible-login"
data-bind="submit:login"
method="post">
<fieldset id="customer-email-fieldset" class="fieldset" data-bind="blockLoader: isLoading">
<div class="field required">
<label class="label" for="customer-email"><span data-bind="i18n: 'Email Address'"></span></label>
<div class="control _with-tooltip">
<input class="input-text"
type="email"
data-bind="
textInput: email,
hasFocus: emailFocused,
afterRender: emailHasChanged,
mageInit: {'mage/trim-input':{}}"
name="username"
placeholder="Please Enter Your Email"
data-validate="{required:true, 'validate-email':true}"
id="customer-email" />
<!-- ko template: 'ui/form/element/helper/tooltip' --><!-- /ko -->
<span class="note" data-bind="fadeVisible: isPasswordVisible() == false"><!-- ko i18n: 'You can create an account after checkout.'--><!-- /ko --></span>
</div>
</div>
<!--Hidden fields -->
<fieldset class="fieldset hidden-fields" data-bind="fadeVisible: isPasswordVisible">
<div class="field">
<label class="label" for="customer-password"><span data-bind="i18n: 'Password'"></span></label>
<div class="control">
<input class="input-text" data-bind=" attr: { placeholder: $t('Password'), }" type="password" name="password" id="customer-password" data-validate="{required:true}" autocomplete="off"/>
<span class="note" data-bind="i18n: 'You already have an account with us. Sign in or continue as guest.'"></span>
</div>
</div>
<!-- ko foreach: getRegion('additional-login-form-fields') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
<div class="actions-toolbar">
<input name="context" type="hidden" value="checkout" />
<div class="primary">
<button type="submit" class="action login primary" data-action="checkout-method-login"><span data-bind="i18n: 'Login'"></span></button>
</div>
<div class="secondary">
<a class="action remind" data-bind="attr: { href: forgotPasswordUrl }">
<span data-bind="i18n: 'Forgot Your Password?'"></span>
</a>
</div>
</div>
</fieldset>
<!--Hidden fields -->
<!--Hidden fields -->
<fieldset class="fieldset hidden-fields" data-bind="fadeVisible: isPasswordNotVisible">
<div class="field">
<label class="label" for="guest-customer-password"><span data-bind="i18n: 'Password'"></span></label>
<div class="control">
<input class="input-text" data-bind=" attr: { placeholder: $t('Password'), }" type="password" name="password" id="guest-customer-password" data-validate="{required:true}" autocomplete="off"/>
</div>
<label class="label" for="guest-customer-confirm-password"><span data-bind="i18n: 'Confirm Password'"></span></label>
<div class="control">
<input class="input-text" data-bind=" attr: { placeholder: $t('Confirm Password'), }" type="password" name="password" id="guest-customer-confirm-password" data-validate="{required:true}" autocomplete="off"/>
<span class="note" data-bind="i18n: 'If you want to create an account then click on create account button.'"></span>
</div>
</div>
<!-- ko foreach: getRegion('additional-login-form-fields') -->
<!-- ko template: getTemplate() --><!-- /ko -->
<!-- /ko -->
</fieldset>
<!--Hidden fields -->
</fieldset>
And I am using this event to retrieve data created at :
app/code/Vendor/Module/etc/events.xml
<event name="sales_order_payment_save_before">
<observer name="event_for_sign_up_on_order" instance="VendorModuleObserverUserSignup" />
</event>