I'm trying to do something simple with nitrogen in erlang. I have successfully set validation on text fields:
wf:wire(submit, desk,
#validate{ validators=[ #is_required{text=开发者_运维问答"Required"} ]}),
where desk_name is a textbox and submit is the button at the bottom of the page.
I just want to do the same for a panel. However, using this same code does not seem to work.
Is there a way to have validation for fields other than a textbox??
I really appreciate your help! Thank you.
In nitrogen, you can use its documentation to see all that you can do with its elements. These elements are Erlang records. records have fields and you cannot add anything to a record that was not yet there at compile time.
I suggest you read the wf.hrl
file which is the header file for a number of nitrogen elements (you can find it in a path $NITROGEN/apps/nitrogen/include/wf.hrl
), or you could access the documentation for all elements here.
Another thing is, (to me) you sound like you have not yet learned as much erlang as you may need to successfully develop in nitrogen (no offense). Usually, Frameworks developed in erlang will become obvious once you have learned to play with the language's data structures. you will easily understand why a developer of a given library chose to do something the way you see it. I therefore suggest (with due respect) that you look at this good guide to Erlang Programming.
Most new developers in nitrogen get "Erlang errors" other than "Nitrogen errors" in most of their code.
Do not forget that you can use only as much functionality on a nitrogen element as has been built around the element through its record structure and support action functions. read the documentation, and you will be successful!
success!
精彩评论