See comments below.
On Mar 8, 2012, at 5:38 AM, Natanael Copa <ncopa_at_alpinelinux.org> wrote:
> I'm trying to create some form validation via jquery in ACF but
> discovered that forms are generated by some displayform*()
Yes, these are helper functions with generic HTML display of CFE elements. By all means, you can write your own Lua code to generate HTML as you wish. In most instances, you can just use the helper functions.
> I am a bit confused here.
> How can I add for example an id to a form <form id="myform" ...>
> without re programming the entire framework?
Why would you need to add an element that the action is not going to know about?
That being said, you can write out any HTML that you want within the view file. If you would like to still use the helper functions but put some extra HTML in the middle of the form, there are two things you can try:
1) Modify the form CFE before calling the helper function. This is done fairly often for minor changes like marking one field as read only.
2) If you look at the htmlviewfunctions.lua (or viewfunctions.lua file depending on acf-core version) you will see that the display form function calls a bunch of public sub-functions that you can call directly. This is also done in several ACF pages.
> What would be the preferred way to do jquery form validation? (so users
> does not need post the form if form data does not meet given
> restrictions, for example text input field with integer only)
You can add jQuery validation code without any changes to the generic HTML helper functions. The are also several examples of using jQuery in views. You can use an on-submit trigger like normal.
> Is not the entire point with MVC to separate code from layout, so
> layout people does not need code if they want change the layout?
The view is designed to take the Lua CFE table and generate HTML. You need code to do that, regardless if you write custom code for each view or use generic helper functions. Obviously, it's much easier to use the generic helper functions.
> I have a feeling I am missing something fundamental here...
> Unsubscribe: acf+unsubscribe_at_lists.alpinelinux.org
> Help: acf+help_at_lists.alpinelinux.org
Received on Thu Mar 08 2012 - 09:48:49 UTC