• Resolved vashugup003

    (@vashugup003)


    Hi team,

    I am in the process of creating a custom field type for a website. Previously, I used Gravity Forms, which offers robust support for extending fields via the GF_Field class and the Settings API (reference: [Gravity Forms documentation]).
    Recently, I migrated to Forminator Forms and am aiming for similar extensibility. I am able to successfully register a new field by extending the Forminator_Field class and using the forminator_fields hook.

    However, I’ve hit a roadblock with the form builder. Since it’s built in React and the plugin only includes compiled JavaScript files, I am unable to locate or access the source code required to integrate and render our custom field properly in the builder. This has made it difficult to provide a full user interface for the new field.

    Could you please guide me on how I can implement this functionality or whether the source code for the form builder is available anywhere for extension purposes?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @vashugup003,

    I hope you’re doing well.

    I appreciate your detailed information, and I’m glad to know you’ve migrated to Forminator.

    Regarding your query, I have forwarded it to the Forminator team for their internal review.

    Soon we will update you with more information.


    Kind Regards,
    Imran Khan

    Plugin Support Imran – WPMU DEV Support

    (@wpmudev-support9)

    Hello @vashugup003,

    We received an update from the Forminator team. They confirmed that React isn’t the issue here.

    Since the retrieving field type functions are hardcoded, which does not allow for an external new field.


    Kind Regards,
    Imran Khan

    Thread Starter vashugup003

    (@vashugup003)

    So, does this mean there’s no way to add a fully functional custom field, or is there an alternate approach I can follow?

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @vashugup003,

    To render the field on the form you can use the following filter:
     forminator_after_field_markup

    To render the value in the email you can try the following:  forminator_custom_form_mail_admin_message

    A rough example would be as follows:

      add_filter(
      'forminator_after_field_markup',
      function ( $html, $field ) {
      if ( 'text-1' === $field['element_id'] ) {
      $html .= '<div class="forminator-field-text forminator-col forminator-col-12"><input type="text" placeholder="Custom Text" name="custom-field-1" class="forminator-input"></div>';
      }
      return $html;
      },
      10,
      2
      );

      add_filter( 'forminator_custom_form_mail_admin_message', 'wpmudev_custom_value_fix', 10, 5 );
      function wpmudev_custom_value_fix( $message, $custom_form, $data, $entry, $cls_mail ) {
      if ( 2960 !== intval( $custom_form->id ) ) { // Please change the form ID.
      return $message;
      }

      foreach ( $data as $key => $value ) {
      if ( false !== strpos( $key, 'custom-field' ) && ! empty( $data[ $key ] ) ) {
      $message .= $data[ $key ];
      }
      }

      return $message;
      }

      The above is an example reference on what could be done. You’ll need to hire a developer or code it further to meet your specific requirements.

      Please note that providing custom code beyond the above reference is outside our support scope.

      Regards,

      Nithin

      Thread Starter vashugup003

      (@vashugup003)

      Hey Nithin,

      Thank you so much for your input and the sample you provided.

      I’ve managed to render the custom field on the frontend and also in the shortcode preview within the backend earlier as well. However, the issue I’m facing is specifically with the form builder. I’m unable to figure out how to add components or scripts similar to what’s implemented for other fields in the builder.

      I’ve attached a screenshot of the Email field for reference. Could you please help me understand if it’s possible to add a similar modal, settings panel, and field options for a custom field?

      While I’ve noticed the structure of React components inside the built form-script.js file, I couldn’t determine whether it’s dynamically driven from PHP or hardcoded in JS. If it’s hardcoded, is there any supported way to inject or register a custom field along with its settings UI?

      Appreciate your guidance on this!

      Screenshot 1

      Screenshot 2

      Screenshot 3



      Plugin Support Amin – WPMU DEV Support

      (@wpmudev-support2)

      Hello @vashugup003

      Unfortunately, you cannot natively inject a new field into the drag-and-drop UI in the Forminator visual builder using public APIs because, at this moment, there is no public React component registration system or slot for custom fields inside the builder.

      You can still register your custom code with PHP and it will be working in frontend and store data in the submission.

      Best Regards
      Amin

      Thread Starter vashugup003

      (@vashugup003)

      Thanks Amin, for clarifying!

    Viewing 7 replies - 1 through 7 (of 7 total)

    The topic ‘Extending field types.’ is closed to new replies.