I'm not sure how word my question clearly, so here's what I'm trying to do with no success so far (simplified code)
The end result I need on the page is:
<input type="text" class="form-control" id="Colour" name="InputName7" value="<?php echo $InputName7 ; ?>">
I have a function to build this but the value attribute is rendering as a string instead of code... and I end up with "" as the string value. I don't understand why.
Here's how I call the function:
$newItem = SetItemInputTag("Colour", $ItemCount, "<?php echo $InputName7; ?>", FALSE)
Here's function:
function SetItemInputTag($TagId, $ItemCount, $TagValue, $Disabled){
$InputTag = "<input type='text' class='form-control' id='" . $TagId . "' name= 'InputName" . $ItemCount . "' disabled value='" . $TagValue . "'>";
return $InputTag;
}
I appreciate any help I can get!!
I think you just need to use this much .
$newItem = SetItemInputTag("Colour", $ItemCount, $InputName7, FALSE);
instead of this line
$newItem = SetItemInputTag("Colour", $ItemCount, "<?php echo $InputName7; ?>", FALSE)
this is because you are already in php. then why don't you using script-lets in your code inside your function call.just remove that and try.
Change this
$newItem = SetItemInputTag("Colour", $ItemCount, "<?php echo $InputName7; ?>", FALSE);
For this
$newItem = SetItemInputTag("Colour", $ItemCount, $InputName7, FALSE);
It looks like you are already inside of php. Remove the bit and it should work:
$newItem = SetItemInputTag("Colour", $ItemCount, $InputName7, FALSE);
What you can try is using different characters rather than PHP tags to solve your problem. You would have to have another function on your page to go through the result and replace with PHP code.
Let me explain this in code.
Change this
$newItem = SetItemInputTag("Colour", $ItemCount, "<?php echo $InputName7; ?>", FALSE)
To this
$newItem = SetItemInputTag("Colour", $ItemCount, "{{ InputName7 }}", FALSE)
On the view page, you would use regex to find the curly braces and find the value of $InputName7.
Here is a link to replace functionality with regex: http://php.net/manual/en/function.preg-replace.php