The subfields first_name and last_name cannot be saved.
Support › MB User Profile › The subfields first_name and last_name cannot be saved.Resolved
- This topic has 5 replies, 2 voices, and was last updated 3 years, 9 months ago by
Yumikom.
-
AuthorPosts
-
July 5, 2021 at 8:43 PM #29306
Yumikom
ParticipantHi,
My registration form does not allow me to save my first and last name.
I am using mb_user_profile_register to display the MB User Profile custom fields as follows.
Is it possible to make this work correctly with subfields?
By the way, I was able to save "last_name_kana" and "first_name_kana" correctly.[mb_user_profile_register id="user-profile" form_id="form-registration" email_as_username="true" password_strength="false" label_submit="送信する" confirmation="登録を完了しました" label_email="メールアドレス" label_password="パスワード" label_password2="パスワード(確認用)"]
<?php add_filter('rwmb_meta_boxes', 'your_prefix_function_name'); function your_prefix_function_name($meta_boxes) { $prefix = ''; $meta_boxes[] = [ 'title' => __('会員情報', 'your-text-domain'), 'id' => 'user-profile', 'type' => 'user', 'fields' => [ [ 'name' => __('ご担当者名', 'your-text-domain'), 'id' => $prefix . 'group_name', 'type' => 'group', 'class' => 'row-name row-required', 'fields' => [ [ 'name' => __('姓', 'your-text-domain'), 'id' => $prefix . 'last_name', 'type' => 'text', 'required' => true, 'attributes' => [ 'placeholder' => 'ご担当者名 姓', ], ], [ 'name' => __('名', 'your-text-domain'), 'id' => $prefix . 'first_name', 'type' => 'text', 'required' => true, 'attributes' => [ 'placeholder' => 'ご担当者名 名', ], ], ], ], [ 'name' => __('ふりがな', 'your-text-domain'), 'id' => $prefix . 'group_name_kana', 'type' => 'group', 'class' => 'row-name row-required kana', 'fields' => [ [ 'name' => __('姓(かな)', 'your-text-domain'), 'id' => $prefix . 'last_name_kana', 'type' => 'text', 'required' => true, 'attributes' => [ 'placeholder' => 'ふりがな 姓', ], ], [ 'name' => __('名(かな)', 'your-text-domain'), 'id' => $prefix . 'first_name_kana', 'type' => 'text', 'required' => true, 'attributes' => [ 'placeholder' => 'ふりがな 名', ], ], ], ], ], ]; return $meta_boxes; }
Best regards,
YumikomJuly 6, 2021 at 6:03 AM #29316Long Nguyen
ModeratorHi Yumikom,
If you want to register/edit the default fields of users on the frontend, please register them as the top fields, not subfields. The default field IDs seem to not work in a group, I will inform the development team to re-check it.
Please get more details here https://docs.metabox.io/extensions/mb-user-profile/#edit-default-fields
July 6, 2021 at 8:30 AM #29321Yumikom
ParticipantHi Long,
Thanks for the quick confirmation.
I had to use subfields in order to achieve the designed layout.
By all means, please make it work with subfields!In this case, we will use before and after to adjust the layout, or use Javascript to assign the value of the subfield to hidden name="first_name".
Thank you.
July 6, 2021 at 8:45 AM #29322Yumikom
ParticipantHi Long,
One question.
Is there a function to add a class to the input element?Best regards,
YumikomJuly 7, 2021 at 9:39 PM #29353Long Nguyen
ModeratorHi,
No, the setting
class
when registering the field will add custom class to the classrwmb-field
, screenshot https://share.getcloudapp.com/bLukQpjp[ 'name' => __('Display Name', 'your-text-domain'), 'id' => $prefix . 'display_name_', 'type' => 'text', 'required' => true, 'attributes' => [ 'placeholder' => 'ご担当者名 名', ], 'class' => "my-custom-field-class" ],
Then you can the custom class as a selector to track the input.
.my-custom-field-class #field-ID
July 7, 2021 at 9:59 PM #29354Yumikom
ParticipantHi Long,
It's still just adding a class to the wrapper.
I am using a library to auto-fill the zip code.
I needed a class for input, so it would have been nice to be able to set it up easily.
This time, I will add the class to input in Javascript.
Thank you. -
AuthorPosts
- You must be logged in to reply to this topic.