By charlie_ on
Greetings,
I am desperately trying to make use of the cool nicejforms plugin. But I'm stumped as to how to get the needed classes/id's into all the Drupal forms. Would anyone knowledgeable about this type of thing please share
an example to help me get a handle on this please? I would greatly appreciate it. :)
Thank you very much in advance.
--Charlie
P.S. There is a demo here, here, and here. If that helps.
Thanks again.
Comments
You will as far as I can
You will as far as I can tell need three things
You may need the jQuery update module (you may need the dev version) depending on the which version of jQuery the module needs.
@nevetsThank you very much
@nevets
Thank you very much for taking the time to reply. :)
Yes, that is my hope. I want it applied to all the Drupal/Theme rendered form items.
I also added the jquery_interface module.
But wasn't able to figure out where/how to load it according to the directions. The doc's indicate that
the plugin needs to make a call for it. However, there is no such call made in the nicejforms-interface.js
file that comes in nicejforms-interface.zip. The demo
that is included in the zip archive
simply called interface.js (also included in the archive). So I elected to use it instead.
Yes. I already added the declarations in the Themes .css file.
Yes. I've done that also. I have confirmed that the template's page.tpl.php file loads all the required
javascript, and css.
Now, if I could only figure out how to make a form_mod. I think
that that is all I have left to accomplish. I've read, and re-read the form modification
API documentation. But can't quite wrap my mind around it. I'm probably making it
harder that it really is. But until I can do it once successfully, I just can't seem to get
it. :(
If I could finally figure it out. I'd love to create a Module. As once I am able
to figure out how to get this far, all the rest will make sense. :)
Thank you again for taking the time to reply!
Here's hoping for a little example - hint, hint :)
Take care.
--Charlie
OH! I almost forgot to mention; Yes I have a recent enough jQuery (1.23).
So that won't be an issue.
Best wishes.
What sort of form mod do you
What sort of form mod do you want to make?
Hello again, and thanks for
Hello again, and thanks for the reply. :)
OK I've figured out that I can add:
to the top of nicejforms-interface.js to hook the search form. I suppose I'd need to make
more modifications. But this much is correct, right?
In answer to your question (and my goal); I'd like to find a more generic hook
that permits altering the forms globally. Is this possible? If so, how?
Is it enough to simply use:
? Or am I dreaming. It just seems that it would be so much easier this way.
If I was able to grab all form elements as in CSS/DOM via form. Then
all the styling already declared in the nicejforms-interface.js could take care of all
the individual elements.
Not sure if this will work. But I'm going to try to post the contents of nicejforms-interface.js
so you can get an idea of what I'm working with. Here goes...
Hope this helps, and thank you again very much!
--Charlie
I'm not sure, but I can also
I'm not sure, but I can also use the following (nicejforms.js) which doesn't require the interface.js
module. I thought it might be worth noting in case it makes the process less complex. :)
[Edited to remove code; not need here and made discussion hard to follow: nevets]
Hope it helps, and thank you again!
--Charlie
You seem to be making it
You seem to be making it hard on yourself. The only form element you need to modify is the form tag it's self so it has the class niceform. Invoking niceform as in their example will take care of all the rest.
Thank you again for your
Thank you again for your reply.
Well, as I understand it, the classes have already been defined in the nicejforms.js, and the
nicejforms-interface.js files. I've added those declarations to the Themes css file. But what
I'm struggling with is how to add, or inject if you will, those classes
into the Drupal/Theme's forms. Maybe my mind has just turned to mush after reading so much
code, documentation, and the API. But I can't seem to figure out how to add the .niceform
class, or any of it's descendants.
[Edited to remove css; not need here and made discussion hard to follow: nevets]
I've successfully loaded the CSS. I've gotten the JS to load. But without those classes in
the forms. Nothing happens outside the default Drupal/Theme form styling.
I must be missing something really obvious. Apologies in advance. :P
Thank you for your continued patience with me. :)
--Charlie
Adding the class 'niceform'
Adding the class 'niceform' to the form and calling $.NiceJForms.build(); takes care of adding the needed classes to the form elements. You can add the class to the form by placing the following in your themes template.php file
You say you are already pulling in the css and js script so the only other thing you would need in page.tpl.php is
BUT that it turns out is only a starting point as nicejforms does not play nice with Drupal forms and understanding why would take some time.
nevets. You !!!ROCK!!!
Thank you nevets. You !!!ROCK!!!
I greatly appreciate the time you were willing to spend assisting me.
This has really helped me get a better handle on adding classes to
to Drupal generated elements. Sure, I know there are already myrads of other
examples, and a wealth of documentation. But it really makes the
difference when it's specific to something your working with.
Much appreciated.
Sorry to hear. I'll spend some time with it getting myself better aquainted
with the whole process. While you were doing all of this, I was getting
a better understanding of the jQuery library. I (and others) might be
better served if I simply write one from scratch specifically
for Drupal. In my initial reading, it seems as though that might not be
a very difficult task. I wrote a JavaScript OS (operating system) back in
the early '90's. I oughtta be able to write a simple class wrapper, eh? :)
On the other hand, I haven't really messed with JavaScript since the mid
'90's. So, it'll take a bit time to re acquaint myself with it. :)
I can't thank you enough nevets, for all the time you spent on this.
It made a world of difference to me. Thank you.
All the best to you nevets.
--Charlie