Forums / Cotonti / Support / Default value in extra fields for pages not working?

value is not read?

ez
#24661 2010-05-22 02:46
Requires core hacking... I guess..

Here is a thing you could try !!! (no garantees)

in functions.php find:
function sed_build_extrafields($rowname, $tpl_tag, $extrafields, $data=array(), $importnew=FALSE)
{
	global $L, $t, $global;
	$importrowname = ($importnew) ? 'new'.$rowname : 'r'.$rowname;
	foreach($extrafields as $i=>$row)
	{
		isset($L[$rowname.'_'.$row['field_name'].'_title']) ? $t->assign($tpl_tag.'_'.strtoupper($row['field_name']).'_TITLE', $L[$rowname.'_'.$row['field_name'].'_title']) : $t->assign($tpl_tag.'_'.strtoupper($row['field_name']).'_TITLE', $row['field_description']);
		$t1 = $tpl_tag.'_'.strtoupper($row['field_name']);
		$t2 = $row['field_html'];
		switch($row['field_type']) 
		{
			case "input":
				$t2 = str_replace('<input ','<input name="'.$importrowname.$row['field_name'].'" ', $t2);
				$t2 = str_replace('<input ','<input value="'.htmlspecialchars($data[$rowname.'_'.$row['field_name']]).'" ', $t2);


Just comment the following line ! (last line in code above)

// $t2 = str_replace('<input ','<input value="'.htmlspecialchars($data[$rowname.'_'.$row['field_name']]).'" ', $t2);


I think this is were the value is inserted into the input tag...
In page.add.inc this function is called in the following way:

// Extra fields
if(count($extrafields)>0)
{
	$extra_array = sed_build_extrafields('page', 'PAGEADD_FORM', $extrafields, '', true);
	$pageadd_array= $pageadd_array + $extra_array;
}
$t->assign($pageadd_array);

/* === Hook === */
$extp = sed_getextplugins('page.add.tags');
if (is_array($extp))
{ foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
/* ===== */

Notice the '' in the call to build the extrafields, and this means value is empty, so $data is an empty string... and so on..

I looked this up real fast, so don't kill me if it is wrong..

This is just a test, this code should be changed differently.. (Not just comment it out)

(If I am right however... this means that ALL extra fields on pageadd cannot have a default value :/ )
But maybe I am jumping to conclusions too fast....

LET ME KNOW
==- I say: Keep it EZ -==
This post was edited by ez (2010-05-22 03:06, 15 years ago)