Ask Questions and Find Answers
Important:
Ask is now read-only. You can review any existing questions and answers, but not add anything new.
But - don't panic! While ask is no more, we've replaced it with discuss - the new Liferay Discussion Forum! Read more here here or just visit the site here:
discuss.liferay.com
RE: custom form field and preconfigured validation
Hello,
I have build my own custom form field for the forms builder. I have set the settings for my form field through an interface DDMFormFieldTypeSettings that extends DefaultDDMFormFieldTypeSettings.
In liferay forms builder I can place my own form field and set in the validation for it in the properties tab of my custom formfield.
Is it possible to preconfigure the custom form field validation?
I want to place my custom form field and then by default it
should have these validation settings preconfigured:
- the the validation toggleswitch should be true
- the selected 'If Input' dropdown option should be 'does not match'
- the 'The value' input for regex should contain my custom regex string
- the 'show error message' input should contain my custom errormessage string
I think I can do this in my DDMFormFieldTypeSettings class but I dont know how.
I am using Liferay CE 7.3.5ga6.
Sorry to say but you should not rely on forms with Liferay CE 7.3.5ga6 maybe not even with Liferay at all.
We also had a problem with Liferay Forms with this version and decided to not use Liferay for such form-hevy demands. https://liferay.dev/#/questions/development/7-3-5-ga6-formbuilder-desaster/
I was not able to find documentation or help for quite similar demands as you have and this forum is not really heavy frequented anymore after the "style update".
Cheers and Good Luck.
Well I cant find this in the docs either. Thank you Fredi B but this doesnt give much hope.
Is there anybody else who is building own custom form fields who can help here? Or somebody who has some experience or helpful links?
I think this should not be that difficult, but as I said I cant
find any help for this specific thing online :(.
Hi Uwe, I asked this internally and there should be a way to do what
you want via DDMFormFieldTypeSettings
.
The bad news is that this isn't working as expected so there's more investigation needed into why, maybe a bug.
The good news is that you should still be able to do what you want.
Create a *DDMFormFieldTemplateContextContributor
for your
custom field and try to set the custom validation values there, like
in ValidationDDMFormFieldTemplateContextContributor.java.
Hello @Uwe,
did you manage to do this in 7.3? I am having problems creating a form field with settings in Liferay 7.3.6 GA7, do you have a code that you can share that works?
Thank you.
Powered by Liferay™