Forms api: field required and visible only if checkbox is checked ?

I am starting on Drupal 7 and the Forms API, and I'm making my first form.

What I want is to have a textfield that is #required => true and visible only if a checkbox is checked. If the checkbox is unchecked, the textfield must be invisible and not required.

It seems like a pretty basic case. Is there a way to do that without having to do it manually in the _validate function ?

Right now, I have a checkbox and a textfield with the #states parameter set to be visible only when the checkbox is checked. By itself, this is working fine.

My trouble comes when I try to set the #required parameter for the textfield. If I set it to true, then I cannot submit the form, even if the field is invisible.
So, I set the #required parameter of the textfield to a condition on the checkbox value, but checking or unchecking the checkbox does not make the red '*' appear, since the form is not rebuilt just by checking a checkbox.
I figured I needed to make an AJAX call to reload the field, so I added a #prefix and #suffix with a div on the textfield, and set an ajax call on the checkbox, returning the $form["mytextfield"] element to replace the div.

Multi-site not working. I'm able to get apache to point to my multi site directory, but i cant get drupal to see it

I had made numerous changes to files. I changed the host file. I changed http file and the vhost files. I also made the change to sites.php and I made a folder for site1 and site2. I copied the default.settings.php in both locations and changed the name to settings.php. I also added the appreicate alias's in apache.

Javascript files - get a weight

Where can I found in database, some list of javascript files weights? I want to add my javascript file but I don't know which weight I have to add to it. My js file needs that another js files are loaded first so it can use its functions and commands.

Thanks for any advice
Tomas

custom taxonomy term page with multiple views

I need to make taxonomy term pages that have multiple views (giving them a layout that's more like a front page). I want to do this for some vocabularies and not others.

I'm stuck on doing this. It seems like there's many approaches but I can't figure them out. For instance, I'm trying to use a node display (views) for the page and attach blocks to that with Context. But I can't figure out how to pass the taxonomy argument to the blocks.

E-Commerce and Drupal 7

What are my options for developing an e-commerce site, starting within the next couple of weeks? Is D7 ready or should I stick with D6 and ubercart?

Any views welcome

Thanks
Terry

Pages

Subscribe with RSS Subscribe to RSS - Drupal 7.x