Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[form] unable to set default prompt for custom function #2976

Open
alvarolm opened this issue Jan 12, 2024 · 5 comments
Open

[form] unable to set default prompt for custom function #2976

alvarolm opened this issue Jan 12, 2024 · 5 comments
Labels
tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build type/usage Any support issues asking for help
Milestone

Comments

@alvarolm
Copy link
Contributor

alvarolm commented Jan 12, 2024

Bug Report

when setting the default prompt (function) for a custom rule it triggers the error:
Uncaught TypeError: prompt.search is not a function
https://github.com/fomantic/Fomantic-UI/blob/develop/src/definitions/behaviors/form.js#L564

Steps to reproduce

set this defaults before instanciating a form

$.fn.form.settings.rules.mindate = function(value) {
return false;
};

$.fn.form.settings.prompt.mindate = function(v) {
return "custom prompt working!"
}

Expected result

no error

Actual result

Uncaught TypeError: prompt.search is not a function

Testcase

https://jsfiddle.net/0tsurydw/2/

Screenshot (if possible)

image

Version

2.9.3

@alvarolm alvarolm added state/awaiting-investigation Anything which needs more investigation state/awaiting-triage Any issues or pull requests which haven't yet been triaged type/bug Any issue which is a bug or PR which fixes a bug labels Jan 12, 2024
@lubber-de
Copy link
Member

lubber-de commented Jan 12, 2024

The custom prompt has to be provided at type declaration
https://fomantic-ui.com/behaviors/form.html#customizing-prompts

rules: [
          {
            type   : 'myrule',
            prompt : function() {
							return "custom prompt working!"
						}
          }
        ]

See https://jsfiddle.net/lubber/5vre3aLo/3/

@lubber-de lubber-de added type/usage Any support issues asking for help and removed type/bug Any issue which is a bug or PR which fixes a bug state/awaiting-investigation Anything which needs more investigation state/awaiting-triage Any issues or pull requests which haven't yet been triaged labels Jan 12, 2024
@lubber-de
Copy link
Member

Your other approach works too, but only if the central value is type of string (this is something we could improve to also accept functions here)

$.fn.form.settings.prompt.myrule = "custom prompt working!";

https://jsfiddle.net/lubber/5vre3aLo/7/

@alvarolm
Copy link
Contributor Author

understood, in my case the prompt is always generated so it needs to be function, for now it seems i will have to provide it each time with a type declaration

may be in the future I'll implement pr, thanks !

@lubber-de
Copy link
Member

may be in the future I'll implement pr, thanks !

I just did by #2977 😉

@lubber-de lubber-de added the state/has-pr An issue which has a related PR open label Jan 12, 2024
@lubber-de lubber-de added this to the 2.9.4 milestone Jan 12, 2024
@alvarolm
Copy link
Contributor Author

thank you so much !

@lubber-de lubber-de added tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build and removed state/has-pr An issue which has a related PR open labels Jan 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build type/usage Any support issues asking for help
Projects
None yet
Development

No branches or pull requests

2 participants