By selinav on
Hello,
I've doing a module which call a hook_form_alter in a hook_nodeapi.
I'd like to pass a variable in my hook_form_alter to get it in my hook_form_alter, how can I do it?
<?php
function maj_attributs_nodeapi(&$node, $op){
//my tests
// I get a var from the database : $prix_revendeur
if(isset($prix_revendeur)){
drupal_set_message(t('Prix %prix_revendeur .', array('%prix_revendeur' => $prix_revendeur)));
function maj_attributs_form_alter(&$form, $form_state, $form_id) {
if($form_id=='product_node_form'){
// if I do this I have nothing in my field
$form['base']['prices']['reseller_price']['#default_value']=$prix_revendeur;
//but with the code below it works
$form['base']['prices']['reseller_price']['#default_value']='12';
// how can I get the $prix_revendeur var in my hook_form_alter?
}
}
}
}
?>
Thanks in advance for your help
Comments
Why are you wrapping a
Why are you wrapping a hook_form_alter in a hook_nodeapi? That's completely illogical; hook_nodeapi is fired on node events, hook_form_alter is fired on form events. I cannot tell you where to get the $prix_revendeur value, because I don't know 1) which form you're altering and 2) where that value comes from or how it is stored. Can you answer those questions?
Hello, I develop a module for
Hello,
I develop a module for ubercart.
It has a problem with the i18n.
When you translate a product, it get the default value of the node but one field added by the module uc_reseller is not get.
I have doing a hook
if($op=='prepare translation'){
//hook of the node translate form to insert the value of the reseller_price in the field reseller_price.
}
Did you enable and configure
Did you enable and configure the i18nsync module (part of the i18n package)? AFAIK, that should be able to do what you need.
I have enable the i18nsync
I have enable the i18nsync module, but I don't know how to configure it.
Can you give me the path to configure it, please.
Thanks
I cannot look it up right
I cannot look it up right now, but if I'm not mistaken, you can find the i18nsync settings on the edit-content-type page.