Welcome Guest, Not a member yet? Register   Sign In
Include PHP code in variable pass to template, is it possible?
#1

[eluser]RJ[/eluser]
Hello,

I've built a custom form that will display the fields based on a config file. Using CI's form validation I need to include
Code:
<?= $this->lang->line('.$key.') ?>
In a variable and have it be processed in the view. Presently CI is stripping the "<?". First is it possible, second any thoughts on a fix?
Code:
$templ[$key] = '    <div class="oneField">
<label for="'.$key.'" class="preField">&lt;?= $this->lang->line('.$key.') ?&gt;:</label>
&lt;input type="text" id="'.$key.'" value="" name="'.$key.'" class="required" &gt;
<span class="reqMark">'.$print.'</span></div><br />';
}
#2

[eluser]kgill[/eluser]
You aren't going to be able to pass code in a variable, but you shouldn't need to. Is there some reason I'm missing that is preventing you from sending the value that $this->lang->line produces instead of the code?

Code:
$templ[$key] = '    <div class="oneField">
<label for="'.$key.'" class="preField">'. $this->lang->line('.$key.') .':</label>
&lt;input type="text" id="'.$key.'" value="" name="'.$key.'" class="required" &gt;
<span class="reqMark">'.$print.'</span></div><br />';
}
#3

[eluser]RJ[/eluser]
Nope, you are absolutely correct. I was thinking to much! Smile

Thanks @kgill




Theme © iAndrew 2016 - Forum software by © MyBB