Blogs on

Form API

knackforge blog

Drupal form's #tree option

There may be a need to name the form elements in an array structure how the form is built. You can see this in Ubercart checkout pane form's input elements. This is very useful when one has a large multi-part form which can be grouped easily by their POST content's array format.

Eg: panes[delivery][delivery_first_name]

A simple flag on you $form construct array will do the trick. It's the #tree option. For whichever elements you set this #tree option, the element's children will be named with full reference to its parents.

Continue reading →
knackforge blog

Drupal Form API - Overriding required field asterisk

Forms are the essential components of Dynamic websites. At KnackForge we firmly believe and make the best use of Drupal CMF. API forms the backbone of Drupal's success and Form API is the most important among them. When Form API used together with the blend of themeing layer, it gives a fine control to get the desired output.

Forms in Drupal are created using PHP array.

Continue reading →
knackforge blog

How to add AJAX validation to a specific field in node form

Every project is unique and has something new to learn. This fact was realized again in my recent work. As the title says, the task was as simple as adding AJAX validation to a specific field (not for the entire form). While this looked pretty easy at first glance but had to perceive and apply a little crux of Form and Field API.

 

Continue reading →
knackforge blog

How to redirect an user after logging into a drupal 7 site?

The main intention of this post is to provide a basic idea about coding which will redirect the users to a custom page once after logging in. The idea of the post was successfully tested in a sample Drupal 7 site and worked very well in all aspects. Once an user logs in, he will be redirected to his profile page. Is that what he needs to see? Apparently not, in that case it is essential for the site admins to redirect the user to the page that he needs.

Continue reading →