|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
wfrohwein Smarty n00b
Joined: 15 Dec 2008 Posts: 2
|
Posted: Mon Dec 15, 2008 7:58 pm Post subject: Missing javascript |
|
|
I have a php class that dynamically generates a from and returns it as a string which i use to populate a smarty variable called {$FORM}. This works great for all the different field types my class created. But there is one field type called date which uses a javascript calendar to populate the date field. Here is my php code:
function buildDateField($field)
{
$stringField = '<input type="text" id="'.$field['name'].'" name="'.$field['name'].'"';
if($field['class']) $stringField .= ' class="'.$field['class'].'"';
if($field['readonly']) $stringField .= ' readonly';
if($field['onclick']) $stringField .= ' onclick="'.$field['onclick'].'"';
if($field['onblur']) $stringField .= ' onblur="'.$field['onblur'].'"';
if($field['onchange']) $stringField .= ' onchange="'.$field['onchange'].'"';
if($field['style']) $stringField .= ' style="'.$field['style'].'"';
if(isset($this->$field['name'])) $stringField .= ' value="'.stripslashes($this->$field['name']).'"';
$stringField .= "> <img id=\"".$field['name']."_button\" src=\"images/calendar.png\" style=\"cursor:pointer\">";
$stringField .= "
<script type=\"text/javascript\">
Calendar.setup({
inputField : \"".$field['name']."\",
ifFormat : \"%Y-%m-%d\",
button : \"".$field['name']."_button\",
align : \"cc\",
singleClick : true
});
</script>
";
return $stringField;
}
When the template is generated, this is what i see in the source:
<tr><td class="label">Date</td><td class="value"><input id="news_date" name="news_date" class="input-text" type="text"> <img id="news_date_button" src="images/calendar.png" style="cursor: pointer;">
</td></tr>
So if you can see, my javascript was left out when the template was created. Just to be sure i had my class export the form to a txt file to make sure all fields were in place with javascript, which was fine, but only when the template is created is the problem.
Am i doing something wrong?
Thanks |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Wed Dec 17, 2008 12:25 pm Post subject: |
|
|
How do you call that function? _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
wfrohwein Smarty n00b
Joined: 15 Dec 2008 Posts: 2
|
Posted: Thu Dec 18, 2008 10:35 pm Post subject: |
|
|
Celeb wrote: | How do you call that function? |
its in a class that builds my forms. The result from the from is use to populate a smarty variable which displays the form, minus the included javascript that was built at the same time the form was. |
|
Back to top |
|
Celeb Administrator
Joined: 17 Apr 2007 Posts: 1025 Location: Vienna
|
Posted: Mon Dec 29, 2008 8:59 am Post subject: |
|
|
So you're assigning everything but the JavaScript to Smarty and are surprised, that everything but the JavaScript shows up in the output? _________________ Darn computers always do what I tell them to instead of what I want them to do. |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|