2

Am using the Booking Time slot module. The module introduces a "Booking entity".

I want to insert the default drupal 'username' and 'email' fields into the form used in creating a new booking, so that user is able to register while completing form.

Assuming "Booking" was a "Content Type", I would use the inline registration module. However, that option does not exist in this case.

Is there a way to insert the fields or merge the 2 forms?

1
  • You can add two extra fields to the content type and then alter the form to add your custom submit handler where you can programmatically create the user. – arpitr Feb 10 '17 at 8:21
0

To create a new booking, the form for that already contains a (required) entity reference field to an existing user (with field_bt_user). Head over of admin/structure/booking/fields in your own site to get more details on that.

If you however want to add another username and email field, just use "Add new field" on admin/structure/booking/fields for both of those fields.

However, as per your "... so that the user is able to register while completing form ..." (as contained in your question), it appears to me that you want an anonymous user to be able to do so. If that's the case, you'll have to decide about how an anonymous user should complete that form, for the required field field_bt_user. You might think "just make that field no longer required", but I doubt that's a good idea to do, since there must be good reason for this module why that field is required.

Because of what is above, I think you should slightly adapt your workflow regarding that "... so that the user is able to register while completing form ...":

  • Step 1: use the Rules module to intercept a path equal to /admin/structure/booking/add, if it is entered by an anonymous user, and redirect them to the login page, with an option to register and a Drupal message shown to them like "this path can only be used by authenticated users, try again after login" (piece of cake with Rules).
  • Step 2: wait for the login to be completed, and have the authenticated user enter the same path (/admin/structure/booking/add) again. When that happens, the Rules Actions in custom rule as in Step 1 will not be executed anymore (since user is authenticated), while the form is not used by an already registered user.

If you can't solve a problem,

then prevent the problem from ever happening again is a typical plan-b ...

1
  • Currently, the module allows anonymous users to "create new bookings". For our use case that is great, except that in addition, we want an anonymous user to be able to register while completing the form. – seyi Feb 10 '17 at 11:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.