Hello all
I am encouring a strange problem , maybe I am doing something wrong, but I followed some example modules to build my own module functions.
The argument is AJAX and add dynamically form elements, more precisely I need to add multiple form fields on a form, but they aren't simple form element, rather they are a set of fields , a kind of fieldset.
So by clicking an "Add new field" button I need to make a new instance of a fieldset with different fields.Here my code:<?php/** * This function generate the new field tree structure */function my_module_dynamic_field($i) { $form=array(); [...............] $form['my_own_field_text_A'][$i]=array( '#type'=>'textfield' ); $form['my_own_field_weight_B'][$i] = array( '#type' => 'weight', '#title_display' => 'invisible' ); [....................] return $form;}/** * This function alters an existing form adding a new section of fields of my own */function my_module_alter_form(&$form, &$form_state) { $form['ajax_container'] = array( '#type' => 'fieldset', '#title' => t("Dynamic fields"), '#weight' => $form['body']['#weight'] + 1, '#prefix' => '<div id="ajax_wrapper">', '#suffix' => '</div>' ); $form['ajax_container']['items']['#tree']=TRUE; [..................] $form['ajax_container']['add'] = array( '#type' => 'submit', '#value' => t('Add new field'), '#submit' => array('my_module_ajax_field_submit'), '#ajax' => array( 'callback'=> 'my_module_ajax_callback', 'wrapper' => 'ajax_wrapper', 'effect' => 'fade', ) ); if (empty($form_state['n_items'])) { $form_state['n_items'] = 1; } if (isset($form_state['values']['add'])) { $i = $form_state['n_items']; $form['ajax_container']['items'] += (array)my_module_dynamic_field($i); } }function my_module_ajax_field_submit($form, &$form_state) { $form_state['n_items']++; $form_state['rebuild'] = TRUE;}function my_module_ajax_callback($form, $form_state) { return $form['ajax_container'];}?>
The problem is that this code doesn't work correctly, it just add and replace the previous form content with the new field, it doesn't add to the form tree structure the new fields. It seems when I submit the form, that the form elements I have added previously are not registered on the form structure when submitting.
Do you know what I mean?
Hope you understand me because my english is not my native language.
Thanks in advance
Greetings
Drupal Modules
Adding multiple fields with AJAX
Drupal Modules.htaccess recreation
Drupal Moduleshi,
i want to permanently delete .htaccess from /wwwroot/sites/default/files because it is blocking my favicon.ico and my attached files from showing/downloading giving this error
DotNetPanel IIS Modules Error
AuthName directive not found.
File: C:\HostingSpaces\abyooda\strongerstudents.com\wwwroot\sites\default\files\.htaccess
how to permanently delete .htaccess?
note: i use iis7 which use web.config
Hierarchical Select Menu or Select Menus in Content? Possible?
Drupal ModulesHi all! Back again with another crazy question.
How do I get Hierarchical Select Menus to work? I found Leers site, and while it's a great module, it has no step by step instructions to get this thing to work. I tried the suggestions on the readme doc but still do not know how to get select menus working.
I basically need 2 select menus of pages that I have already constructed. These menus would live on a particular page an anonymous user to select. They would click and go to that page.
Here is a snapshot of what I am thinking. Obviously I used menus from another site just for comping but they would need to be in the content area.
Cannot include PHP script
Drupal ModulesI have recently started using Drupal, and I want to embed some PHP scripts of mine in the website. Since I am still developing and trying some things, I am working on my localhost and not yet on a website. When I want to embed my php code, I get the following warning message:Warning: include(src/jpgraph.php) [function.include]: failed to open stream: No such file or directory in eval() (line 4 of C:\wamp\www\DrupalSite\modules\php\php.module(80) : eval()'d code).
This is (a part of) my php code:<?php include ('src/jpgraph.php');include ('src/jpgraph_line.php');include ('src/jpgraph_date.php');
I know it has something to do with the fact that the scripts I want to include cannot be found, I have tried moving them to some different directories, I have tried linking to them in different ways (with a ./ in the beginning, with the full path (c:/wamp.../src/jpraph.php) but I always get this warning..
Can someone help me on this please?
Bug on contributing module : disgracious install folder name, project url and release name
Drupal ModulesHello,
I have contribute a new survey module on Drupal.org 3 weeks ago but the contribute process partially failed :
My module name is : LimeSurvey Synchronization
The module prefix value is : 'limesurvey_synchronization' ('limesurvey_synchronization.info', 'limesurvey_synchronization.module', etc...)
However the name attributed to my module is not the module prefix value but the git number !
There are many consequences :
- The install folder on drupal is 'sites/all/modules/460746' instead of 'sites/all/modules/limesurvey_synchronization'
- The url of my project is http://drupal.org/project/1460746 instead of http://drupal.org/project/limesurvey_synchronization
- The release file name is 1460746-6.x-1.0-beta2.tar.gz instead of limesurvey_synchronization-6.x-1.0-beta2.tar.gz
The module is functionnal, it can be reached, downloaded, installed, but this is quite ugly (especially concerning the install folder) and may discourage users installing my module.
Insert form value to database field - Bit new at this!!!
Drupal ModulesHello,
I have general PHP knowledge but I'm quite new at Drupal, so I require bit of assistance on this matter, since drupal api is still bit confusing for me (day 3 of module developing)...
First off, I have read API for related matter so do not direct me there again plz, I just can't seem to figure out how to make it work still, hence I am here :)
What I need to do (should be simple eh) when I submit a form I want to insert specific value in a specific field in database, for example:
form fields: organization name, e-mail, address....
organization name = name in table users
e-mail = mail in table users
but address = address in different_table
hook_schema for existing table
Drupal ModulesI have an existing table and wrote a hook_schema for it. When I install my module, hook_schema is called and tries to create the table. Since it exists, it is not created and the schema is available to Drupal. But if I uninstall my module my existing table is dropped. I know that this has been changed in D7, but in my case the table has to be kept untouched. I don't need special CRUD operations, just to access the data with read-only operations in a nice way.
The other method I tried is to expose the table to Views, but I rather need an array with my data to process it further in my own module.
How to set a default configuration for module using PHP file?
Drupal ModulesHi,
I have a dir for modules that is provided as a feature in /sites/all/modules/my_module/features
where a sub-folder contains a module,
e.g. /sites/all/modules/my_module/features/advanced_forum/
and for each module i want to create a php file that is handling default configuration and is run on activation of a feature:
/sites/all/modules/my_module/features/advanced_forum.php
It’s important that the contributed module is just placed directly in the features library so they can be updated, without having to do anything else then replace the folder. Of course configuration script might have to be changed on updates, if the module changes radically.
how to add block in search-result.tpl.php??
Drupal ModulesHello,
I want to add my custom module in search-result.tpl.php.
i have custom module with featured restaurant and i have to display featured restaurant on search result page for that i have write below code for rendering block.
if($page[featured_restaurant]):
print render($page[featured_restaurant]);
endif;
but this code is not working for me and i have done some debug i found that on search result page i am not getting $page variable.
please help me for this point
Thank you
Views3: "Expose the filter to the visitor" not available
Drupal ModulesHi.
I have two Drupal-Installations with Drupal 7.12 and the Views-Module 7.x-3.3 but different content and some other Modules.
At one of these Drupal-Installations I can't set the option "Expose the filter to the visitors". The option is missing in the configuration dialog of all my views. But the option has been there some time ago.
I can't say when exactly this option vanished. By changing an option somewhere in the system or by adding a module?
I compared everything, but I can't find differences that can cause my problem?
Has somebody an idea?
Thanks!