By lemask on
hello all,
i want to write a module who can interact with an another module (simplenews ).i have added a function in my module to alter the form of the old's form module. the problem is that i have to add two field in the new form .my function is:
function mynews_form_alter($form_id,&$form){
if($form_id == 'edit-simplenews-block-form'){
$form['com_connu']=array(
'#title'=>t('comment avez vous connu '),
'#type' =>t('textfield'),
'#description'=>t('connaitre '),
);
$form['quel_boutik']=array(
'#title'=>t('quel boutique aimeriez vous'),
'#type'=>t('textfield'),
'#description'=>t('quel boutik'),
);
}
}
but when i see the block in my website the old form don't change i don't know why.
so i need some help.
thanks in advance.
Comments
It looks like the simplenews
It looks like the simplenews form is being built after your form_alter hook is being executed, eg your module is running before Simplenews because by default they run in alphabetical order. You can change the weight of your module to 1 to make it run after simplenews and then the form should be updated as required. This is in the system table, weight column.
Hi, could you explain more
Hi,
could you explain more i don't know how to control the weight of the module.
thanks you
you will need access to
you will need access to phpmyadmin to manually update your database. The 'system' table is used by drupal to store all the paths to modules and themes. This table includes a column 'weight' that by default is set to 0 meaning that all modules have the same weight and will therefore be included/loaded alaphabetically. To override this and specify an order to load the modules (which is what you need to do in order for your hook_form_alter function to be called the simplenews form function) you should update the weight value for your module to 1, so that Simplenews has a weight of 0 and is therefore loaded first.
hope this makes more sense.
You might also want to try
You might also want to try the Module Weight module.
http://drupal.org/project/moduleweight
http://www.trailheadinteractive.com