| home | resources | search | news | join | members: 6958 |
Hiveminds | Sun, 2007-08-26 11:20 tags: Portals, Drupal, Web Developer This a step by step for overriding a form element that is built by one module and then changed by another. The module doing the overrride must be loaded after the originating module and its form. You can do this by naming the override module to load after the originator. Modules are loaded in alphabetical order unless set by weight. All modules have a default weight of 0. To change this go into the stystem table of the database, find the rows with the modules to be used and change the weights to a numerical order of 1 and 2. The code for the override is standard but in order to make anything happen you will have to learn the names of the form elements by looking at the HTML code. This is where the Drupal documentation fails becausse it does not tell you how to properly get the names of the elements. The easiest way is to look at the source code. When getting the names though you have to be careful to not include the prefixes that are added in by the system. The system usually adds in "edit-" to a form element. You must also remove any "+" characters in names. These are added to satisfy the web browsers need to concatenate names with spaces. Here is a screenshot of the form I am going to change by activating a module called "profilecloud" what it is add freetagging terms to the description of the textarea. ![]() This the default look after the profile textarea has been created by using the profile module. You may want to experiment with the creation of profile forms before attemping to override them via antoher module. This will give you and idea of what to expect when you look at the source code. ![]() In the above image you will see two sections. The top section the the source code of the profile page that has the form. The second section is the PHP code in your module that uses hook_form_alter(). Here I am going to change the description text of the textarea. You do this by entering the names of the form, the profile category and textarea into the function as an array element. The arrows show where the text should be placed. As mentioned earlier you have to follow the naming rules for the function which are different from those used the make up the form. Here is a snippet of the exact code I used to make the change.
<?phpAfter adding in function profile_form_alter with the right code to the profileclould module and then activating it it looks like this. ![]() This article brought to you by the
Hiveminds Magazine - Staff. Contact us if you want to post an article or announcement anonymously Thoughtbox - So what did you think? |
Content Management Systems London Hotels
Drupal Laptop Reviews
Wordpress Just Dial International Calls
Content Management Systems Excel Training Courses
Joomla! excel courses in london
Adobe Flex Web Developers Data Recovery
|
NewsletterGet updates on Hiveminds services, articles and downloads by signing up for the newsletter. |
Editor's choiceSome of the better articles, stories and tutorials found at Hiveminds. |
Find moreFind more of Hiveminds articles, stories, tutorials and user comments by searching. |
Picked linksHand picked websites and articles from around the web that provide quality reading. |