Skip to main content
Version: v4

Form Bubble

The CometChatFormBubble component is used to render a form within a chat bubble. The form fields are dynamically built based on the data passed in the message prop. The form fields can include text inputs, checkboxes, radio buttons, dropdown, labels, single selects, buttons. Once the form is filled out and submitted, the data will be sent to the provided URL or handled by a custom function.

Methods

MethodsParametersDescription
setFormMessageFormMessageAn instance of the FormMessage class which holds information about the form fields. The form inputs are dynamically built based on the form fields' information in the message.
setStyleFormBubbleStyleInterfaceAn object of styles for customizing the UI of the form bubble. You can override styles for the wrapper, title, goal completion text, and form inputs, etc. If a style is not provided, the default style will be used.
setOnSubmitClickOnSubmitClickA Callback that will be called when the form is submitted. This function receives the form data as an argument.

FormBubbleStyle

FormBubbleStyle is a class containing attributes to customize the appearance of the CometChatFormBubble component.

MethodsTypeDescription
setBackgroundUIColorUsed to set the background color of the form bubble.
borderBorderStyleUsed to set the border of the form bubble. The object should include borderWidth and borderColor.
setCornerRadiusCGFloatUsed to set the border radius of the form bubble.
setTitleColorUIColorUsed to set the color of the title.
goalCompletionTextFontUIFontUsed to set the font style of the goal completion text. The object should include fontFamily, fontSize, and fontWeight.
goalCompletionTextColorUIColorUsed to set the color of the goal completion text.
textInputStyleTextInputStyleInterfaceUsed to customize the style of text input fields.
quickViewStyleQuickViewStyleInterfaceUsed to customize the style of the quick view.
radioButtonStyleRadioButtonStyleInterfaceUsed to customize the style of radio buttons.
checkboxStyleCheckBoxStyleInterfaceUsed to customize the style of checkboxes.
dropdownStyleDropDownStyleInterfaceUsed to customize the style of dropdowns.
labelStyleLabelStyleInterfaceUsed to customize the style of labels.
buttonStyleButtonStyleInterfaceUsed to customize the style of buttons.
singleSelectStyleSingleSelectStyleInterfaceUsed to customize the style of single select fields.

Usage

  let formBubble = CometChatFormBubble()
if let controller = controller {
formBubble.set(controller: controller)
}
if let message = message {
formBubble.set(formMessage: message)
}