Skip to content

Commit dab8b22

Browse files
Clean up empty HTML and help text in form inputs
1 parent 29ef44d commit dab8b22

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

api/app/Http/Requests/UserFormRequest.php

+15
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,21 @@
1414
*/
1515
abstract class UserFormRequest extends \Illuminate\Foundation\Http\FormRequest
1616
{
17+
protected function prepareForValidation()
18+
{
19+
$data = $this->all();
20+
21+
if (isset($data['properties']) && is_array($data['properties'])) {
22+
foreach ($data['properties'] as &$property) {
23+
if (isset($property['help']) && strip_tags($property['help']) === '') { // Remove help if it's empty
24+
$property['help'] = null;
25+
}
26+
}
27+
}
28+
29+
$this->merge($data);
30+
}
31+
1732
/**
1833
* Get the validation rules that apply to the request.
1934
*

client/components/forms/RichTextAreaInput.client.vue

+8
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,14 @@ const emit = defineEmits(['update:modelValue'])
9595
const { compVal, inputStyle, hasError, inputWrapperProps } = useFormInput(props, { emit })
9696
const editor = ref(null)
9797
const mentionState = ref(null)
98+
99+
// Add this watch to clean up empty HTML content
100+
watch(compVal, (val) => {
101+
if (val && val.replace(/<[^>]*>/g, '').trim() === '') {
102+
compVal.value = null
103+
}
104+
}, { immediate: true })
105+
98106
// Move the mention extension registration to onMounted
99107
100108
if (props.enableMentions && !Quill.imports['blots/mention']) {

0 commit comments

Comments
 (0)