This forum is for module development and code related questions, not general module support. For general support, use the Post installation forum.

Java script in My Module

I've got a Drupal module that creates nodes. In my node_form hook I have several form fields that are returned. For several reasons I need to access those fields on the fly in javascript ... here's the problem.

Drupal creates form fields like this

------------
<form action="/node/add/song" method="post" name="frmSongForm" enctype="multipart/form-data" id="node-form">

<input type="text" maxlength="64" class="form-text required" name="edit[firstname]" id="edit-firstname" size="40" value="The Yellow Dart" />

</form>
-------------

This is nice and makes my life easier on the php side, but it makes things a big problem when I try to get a handle on the field in javascript! For instance I try the following:

-------------
firstname = document . frmSongForm . edit[firstname] . value;
-------------

And javascript says 'undefined!'. I have looked high and low for a way to get a grasp on these form fields using javascript and nobody seems to have a solution. Am I missing something obvious here? Or is this truly impossible.

PS: Yes, If I make up my own form field I can access it just fine. However, this is nasty and a hack. For instance, the following code works just fine (NOTE: The name of the field!):

-------------

/?q=username , is this possible?

Hi all,

I'm developing a module where each member has their own page, and would like members to be able to access there own pages and other peoples pages via -

www.mydrupalsite.com/?q=username or www.mydrupalsite.com/username

(a member's page isn't private anyone can access it)

How to validate form elements (In a modified, but existing form) using 4.7 forms API?

Okay, perhaps I'm just easily confused, but I cannot make heads or tails out of form validation.

I am attempting to perform validation on a field that has been added to an existing form.

I've added a textfield to the form that appears on admin/settings/content-types/(nodetype), and I want to be able to make sure that a positive integer is entered into that field.

I'm attempting to create a very simple module to limit the number of nodes that can be created per user, per node type, and I wanted to add a field to the admin/settings/content-types/(nodetype) page, where the admin could enter an integer for how many nodes of that type that each user could create.

Now, the easy part was creating the alter_form thingy, to add the appropriate field to the form. I got that working just fine. It saves to the database properly and everything.

But then I wanted to make sure that the admin entered an a positive integer or zero. Glancing through the API, I'd seen an attribute for form elements, "#validate", and thought it would be simple. Here I sit, eight hours later, completely frazzled.

The sample code on the Forms API Reference page either doesn't work, or I completely don't understand it.

The code in the Forms API FAQ entry (http://drupal.org/node/36899) under "How do you use the #validation arguments?" doesn't even _look_ like it would work (no quotes around #valid or #validation arguments)

categories broke edit - i disabled, now site gone.

I had just started putting a new site together with 4.7 from CVS from a couple weeks ago.

I am sort of new to Drupal but was pretty sure I needed to use tox to classify my nodes. I have only added a few nodes so far but had added terms to them. I then started to try out a couple other tox mods to see how this all worked; I had the tox_block and tox_theme mods working fine.

Then I figured I should likely start looking at categories since I thought this was likely the way I SHOULD be doing this.

I went through install process (even though I think install.txt is a bit confusing) - but I think I did things correctly. I imported my existing nodes from one vocab to a category. This worked fine.

NOW... the issues:

- some of my nodes don't show up as orphans - no big deal

- when I am logged in as admin and I go to a node - I can no longer EDIT the node

- I read a post about this and someone suggested disabling/enabling categories to fix this.... OOOPS!!

- once I disabled "Categories" module and hit save; my site was gone.

I get " Call to undefined function: category_select_nodes()"

So I guess it makes sense that I wouldn't be able to find this function since I just disabled it - but pretty sure it shouldn't kill my site.

Hopefully just removing the category mod will repair this - but I kinda doubt it... stay tuned...

Have I installed something incorrectly here?

NOTICE-BOARD

How do you do!
We Beg pardon for my english since write by means of translator.
I interest the module a NOTICE-BOARD for accomodation of information on car, there is such marketed under Drupal.
Respectfully yours, Mihail.

Block access control and database

I'm modifying block.module to allow Drupal to display blocks based upon the role a user is assigned. I have this code:

  $rroles="SELECT name FROM role";
  $rrroles = db_fetch_array(db_query($rroles));
  
	   foreach ($rrroles as $reles => $names) {
		    $options = array();
		    $options[] = t($names);
	    }

But it only returns one result. I've tried a while loop but the page hangs. All help would be deeply appreciated.

Pages

Subscribe with RSS Subscribe to RSS - Module development and code questions