Page 1 of 1

[Solved] form builder, bilingual labels

Posted: Mon Jun 09, 2008 3:59 pm
by marties
Hello,

i'm planning to use the form builder on a bilingual website (english/french) the form i design will send email and write the result to a csv file.

How would you design a unique form with labels in french or english (according to the page) but with same id/name for the elements so that the submitted form will write in the same csv file ?

I also can't manage to have labels correctly encoded in french independently from the form elements (input, select...)


Thanks a lot for your advices


ps: cms is 1.3, formbuilder is 0.5.3

Re: form builder

Posted: Mon Jun 09, 2008 4:34 pm
by calguy1000
Formbuilder (infact most modules) doesn't support multilang.

But for simple label translations, this can probably be done with a few simple modifications to the module, a template rewrite, and a few small module_custom/FormBuilder/lang/.php files.

1) do a backup
2) in FormBuilder/FormBuilder.module.php:DoAction
    add:  $smarty->assign_by_ref('formbuilder',$this);
3) in your form templates, change this stuff:

Code: Select all

<label{if $entry->multiple_parts != 1} for="{$entry->input_id}"{/if}>{$entry->name}
to

Code: Select all

<label{if $entry->multiple_parts != 1} for="{$entry->input_id}"{/if}>{$formbuilder->Lang(entry->name)}
4) Create two files:
module_custom/FormBuilder/lang/en_US.php
module_custom/FormBuilder/lang/fr_FR.php

and in those php files (so you need at the bottom
add lines like this:
$lang['XXXX'] = 'something';
where XXXX is the field names you've created.

Re: form builder

Posted: Tue Jun 10, 2008 9:08 am
by marties
Thanks for your help,

i'm stuck with these errors while browsing the page :

Notice: Undefined variable: smarty in /home/biodev/www/modules/FormBuilder/FormBuilder.module.php on line 181

Fatal error: Call to a member function assign_by_ref() on a non-object in /home/biodev/www/modules/FormBuilder/FormBuilder.module.php on line 181



Here is what i've done :

1- in /config.php i've enabled smary tags
$config['use_smarty_php_tags'] = true;

2- in /modules/FormBuilder/FormBuilder.module.php:DoAction  (you mean in the DoAction function !? Yes ?)

i have added the smarty line (line 181 in the file)

function DoAction($name,$id,$params,$returnid='')
{
$smarty->assign_by_ref('formbuilder',$this);
$this->module_id = $id;
parent::DoAction($name,$id,$params,$returnid);
}

3- i've modified the form template accordingly

4- created the two files in /module_custom/FormBuilder/lang/


Thanks

Re: [Solved] form builder, bilingual labels

Posted: Fri Jun 13, 2008 10:07 am
by marties
Hello,

as there was no news from anyone to my post and as the answer from Calguy1000 (thanks a lot anyway for your time spread) unfortunately didn't work, i made the labels show both language on the same form.

For example:

First name / Prénom

After the submit i redirect on a thank you page accordingly to the language.

Re: form builder

Posted: Fri Jun 13, 2008 11:15 am
by Sonya
marties wrote: $smarty->assign_by_ref('formbuilder',$this);
should be
$this->smarty->assign_by_ref('formbuilder',$this);

Re: [Solved] form builder, bilingual labels

Posted: Fri Jun 13, 2008 11:59 am
by marties
too bad it's a bit late

i'll try for my next dev

Thanks