In this example, we will update the field attributes of the newly added repeat group item.
// Listen to all form field initialize events
window.formyoula.form_entry.on('form:field:initialize', function(options) {
// Update field
update_field_attributes(options.view.model);
});
// Function to update specific field attributes
function update_field_attributes(field) {
// Check if this is the field we want to update based on the field ID or Lable
if ( field.get("component_id") == "32c0-a4cf-729a" || field.get("label") == "Checkbox Field" ) {
// Check if field is inside repeat group
if ( field.get("attributes").repeat_entry_id ) {
// Add the new field attributes we want to change
var custom_html_attributes = [
{
attribute: "style",
type: "label",
value: "color: green;"
},
{
attribute: "disabled",
type: "input",
value: "disabled"
}
];
// Update the field with new attributes
field.get("attributes").options = custom_html_attributes;
// Update target field to read-only
field.get("attributes").readonly = 'yes';
// Update value
field.set({
value: true,
required: true
});
}
}// END Checkbox field update
}// END update_field_attributes
For any questions, please contact us - [email protected] or the Formyoula in-app chat 🙂