I am trying to get the list options in a form to translate, but so far no luck. I can’t find how to code it properly. Tried the first option of the array to translate but it throws a syntax error:
in my new_form.class.php I have:
var $consciousness var $consciousness_array = array("1" => '<?php echo xl('bright and alert'); ?>', "2" => "uncontrolled/hyperexcitable", "3" => "sopor", "4" => "stupor", "5" => "coma");
How do I do this? The only way the list is working is when I changed some " or ’ characters but then it only shows the code in the list and not the translation.
In my general_new.html it reads, and it works…: {html_options name="consciousness" selected=$data->get_consciousness() options=$data->consciousness_array}
I am doing something wrong with " or ', but can’t figure it out. Any help greatly appreciated.
@sjpadgett
thanks, me neither, me no developer just a vet, so if you don’t get it right I’ll have to do trial and lots of errors…
@stephenwaite
thanks for the links, not sure what all that means yet, but I’ll try it.
I remember seeing the translation trick inside a listbox in some of the 60+ contributed forms, but I cannot remember which it was…
Roland
thanks Brady, tried it, but now it says: PHP Fatal error: Constant expression contains invalid operations in /var/www/git-openemr/interface/forms/vet_genphys_exam/Formvet_genphys_exam.class.php on line 36, referer: ...localhost/git-openemr/interface/patient_file/encounter/forms.php
I thought that maybe I couldn’t use code words like “alert” “and” or a slash, but that doesn’t change anything.
Class variables generally need to be static. Would need to set this var in the class constructor. Something is not right here, though, and rec posting your form on github so we can look at the entire form.
Just trying to figure out why the echo inside the array if a class array. Plus, however it is defined, still need to json encode if heading to javascript…,
I also initially thought it was js because of the echo and var. But pretty sure it’s straight php for a class var. Will be very helpful to see the entire form to sort out this mystery
yes, brady, it is php class var.
The form is a variant of Aron’s Racho’s ros2 review of systems form. It works fine, everything also translates ok, except the list choices, wanted to do that too.
So I thought why not move all the list choices (written in html that work fine, also easy to translate) to arrays in the Form…class.php, there are so many listboxes (see screenshot)
In the wonderful world of github where all your childhood dreams will come true (I may be exaggerating just a bit)…
First step is to set up a git/github repository via the following tutorial (note that using git/github is well worth learning and will make it much easier for you to code, track your changes, get coding help from community, and integrate your code changes into future OpenEMR versions; and it’s just plain fun (again, I may be exaggerating again)): http://www.open-emr.org/wiki/index.php/Git_for_dummies
(ignore the video)
Ok, I was just going out to find the nearest lamppost and hang myself for not getting this to work…
Maybe github is the solution, so I’ll just go out for a slice of pizza (which almost equals slower suicide) and watch the video.
A bit nervous though, I hope my “code” will not be met with sarcasm, for I am no developer and it only applies to our non-human friends, but if I can get my things done, I can handle it as a dummie vet…
Hi guys,
thanks for all your comments. Forget the arrays, it was driving me crazy; my solution was maybe a bit lame for a beginning developer, but now the form works and it translates ok, also the options.
I did : <select name="consciousness"/> <option value="BALR">{xl t="bright/alert/responsive"}</option> <option value="UNHY">{xl t="uncontrolled/hyperexcitable"}</option>
There’s still one thing: the listboxes do not keep their selections. How to achieve this? I studied all day on the internet and found some snippets, but there is a guy in the background of OpenEMR called Smarty and he doesn’t like what I’m doing. The code is either commented out and all converted to lowercase, when I write this: <select name="consciousness"/> <option value="BALR" <?php if($_POST['consciousness'] == 'BALR') echo "selected=selected"; ?>{xl t="bright/alert/responsive"}</option>
or he throws an unrecognized tag ‘echo’ error at me, and the form doesn’t display at all, when I do this:
Problems solved; the solution was in OpenEMR itself, the vitals form has all the answers, translation, arrays and keep selections and all… next time I’ll look into OpenEMR instead of the internet first.
My form now works fine… time to give something back to the community, anyone interested in a veterinary general phys ex form? …
If I understand how to github, I’ll post it there…
no more hanging from lampposts
R
nice @roland !
Definitely interested in a vet phys ex form for the project
If git/github guides you towards another lamppost, always feel free to send me the form (and I’ll post it to github).
-brady