Location: PHPKode > scripts > Dornbase > scripts/graph_form.php
<?php
requireLogin();

$defaults = array(
	'type'=>'bar',
	'field'=>'',
	'fields'=>'',
	'xmin'=>'auto',
	'xmax'=>'auto',
	'xscale'=>'auto',
	'ymin'=>'auto',
	'ymax'=>'auto',
	'yscale'=>'auto',
	'num'=>5,
	'display'=>'percent',
	'bestfit'=>'false'
);
$record = new Record();
	
function getGraphForm() {	
	global $site_root,$current_path;

	//get starting params for form
	global $defaults,$record;
	$values = array();
	foreach($defaults as $param=>$value) {
		if(isset($_REQUEST[$param])&!empty($_REQUEST[$param])) $values[$param] = $_REQUEST[$param];
		else $values[$param] = $value;
	}
	
	ob_start();
?>
<form method='get' action='<?php echo url($current_path); ?>'>
	<input type='hidden' name='id' value='<?php echo $_REQUEST['id']; ?>' />
	<input type='hidden' name='action' value='<?php echo $_REQUEST['action']; ?>' />
	
	<label>Type</label>
	<select name='type' id='type'>
		<option value='bar'>Bar Graph</option>
		<option value='bar'>Pie Chart</option>
	</select><br/>
	
	<div id='extra_options'>
		<?php include SITE_FOLDER."utils/graph_".$values['type']."_form.php"; ?>
	</div>
</form>
<script type='text/javascript'>
$(document).ready(function() {
	<?php
	foreach($values as $field=>$value) {
	?>
	$("#<?php echo $field; ?>").val("<?php echo $value; ?>");
	<?php
	}
	?>
	$("#title").val("<?php echo $_REQUEST['title']; ?>");
	$("#type").change(function(){
		$("#extra_fields").load('<?php echo url("graph/form/"); ?>'+$(this).val()+'/');
	});
});
</script>
<?php
	$html = ob_get_contents();
	ob_end_clean();
	return $html;
}
?>
Return current item: Dornbase