Форумы / Cotonti / Support / Default value in extra fields for pages not working?

value is not read?

GHengeveld
#24514 10.05.2010 01:05
I'm guessing that has something to do with the value being set by Cotonti when generating the field. This is necessary to keep the value in the field when an error occurs (otherwise you'd have to completely fill in the form again).
If you want to set a default value, a simple solution would be to use jQuery. You can just add the JS at the end of the template file (page.add.tpl for example).

<script type="text/javascript">
$.fn.defaultValue = function(val)
{
	return this.focus(function()
	{
		if(this.value == val)
		{
			this.value = "";
		}
	}).blur(function()
	{
		if(!this.value.length)
		{
			this.value = val;
		}
	});
};
</script>

<script type="text/javascript">
$(document).ready(function(){
	$("input[name$=extra1]").defaultValue("Some default value");
});
</script>