Page 1 of 1
FrontEndUser : get name of form element in templates?
Posted: Fri Dec 15, 2006 5:39 pm
by simb
Hi,
I want to use the FrontEndUser module and customize the included module templates therefor.
Unfortunally I can't find a way to get out the name or id of the field in the loop in the change settings template. I need it to put a label in front of it.
I even can't find the right place in the code to patch it.
Any hints or ideas?
Greetings
simb
Re: FrontEndUser : get name of form element in templates?
Posted: Fri Dec 15, 2006 7:19 pm
by calguy1000
Well, it may be possible without a code change.
Field names are prefixed with the page id when their generated, and if the page id is available in smarty, then you can generate the label yourself.
I'd add {get_template_vars} into the top of the template, and see what smarty variables are available.
Then do a view source of the page, and see what the generated field name is. something like m1blahblah
if you can match up the "m1" part with a smarty variable, then you can add the label easily.
Re: FrontEndUser : get name of form element in templates?
Posted: Thu Dec 21, 2006 1:24 pm
by simb
thanks calguy1000 for the reply.
Unfortunally, I don't understand your hint very well or maybe I couldn't explain my problem good enough.
Here is it more detailed
I want to modify the change settings template. In it, I have a loop:
Code: Select all
{foreach from=$controls item=control}
{$control->hidden}<label for="">{$control->prompt}{$control->marker}</label>{$control->control}<br/>
<div class="hint">{$control->addtext}</div>
{/foreach}
as you see, I want to put a in front of each form element. The syntax is to say
Code: Select all
<label for="nameofthelementtolabel">Labeltext</label>
My problem is, that I can't find the variable which contains the name, as it is already in {$control->control} included.
Did I miss the variable? {get_template_vars} didn't help.
Your help is very welcome!
simb
SOLVED: FrontEndUser : get name of form element in templates?
Posted: Fri Dec 22, 2006 7:00 am
by simb
I was able to find the right place in the code at line 4548 in file FrontEndUsers.module.php
Code: Select all
...
//output the name of the elements to use e.g with labels
$onerow->myelemname = $id.'input_'.$prop['name'];
array_push( $rowarray, $onerow );
}
...
This way I have the additional variabel "myelemname" to use in the template:
Code: Select all
...
{foreach from=$controls item=control}
<div class="formline">{$control->hidden}<label for="{$control->myelemname}">{$control->prompt}{$control->marker}</label>{$control->control}<br/>
{if $control->addtext != ""}
<div class="hint">{$control->addtext}</div>
{/if}
</div>
{/foreach}
,,,
maybe it helps someone else also.
greets
simb