kevinchappell / formBuilder

A jQuery plugin for drag and drop form creation
https://formbuilder.online
MIT License
2.63k stars 1.39k forks source link

Can i remove Select / Radio / Checkbox Value field and set Default value as per Text #1336

Open raviozainfo opened 2 years ago

raviozainfo commented 2 years ago

Description:

Hi, I want to remove Value from Select / Checkbox / Radio in option and need to set value as per Its Text. Or its ok if what i am typing in text fields will auto set in Value.

Environment Details:

Expected Behavior

image

Actual Behavior

Steps to Reproduce

Screenshot - (optional)

lucasnetau commented 1 year ago

Not directly in formBuilder but you could try the following

The options are wrapped by

Add styles to hide the value and expand the label

.form-wrap.form-builder .frmb input.option-label.option-attr {
    width: calc(89% - 17px) !important;
}
.form-wrap.form-builder .frmb input.option-value.option-attr {
    display: none;
}

then hook into the input event to update the value field when the label field is changed

$('#fb-editor').on('input','.form-wrap.form-builder .frmb input.option-label.option-attr', (event) => {
    $(event.target).siblings('.option-value').val($(event.target).val());
});

NOTE: I haven't tested this in practice, it should work but code will need to be double checked