}
    if ($p_slug != '' && !preg_match('/^[a-zA-Z0-9_-]*$/', $p_slug)) {
        $success = false;
        array_push($errors, "Invalid slug!");
    }
    if ($p_slug == '') {
        $success = false;
        array_push($errors, "The slug field is required !");
    }
    if ($success) {
        $update = array('name' => $p_name, 'slug' => $p_slug);
        if ($region['parent'] > 0 && $p_parent > 0) {
            $update['parent'] = $p_parent;
        }
        Region::update($g_id, $update);
        $region = Region::get_one($g_id);
    }
}
$regions = Region::get_all(array('parent' => 0));
include "page-header.php";
?>

<div id="wrapper">

	<?php 
include "page-left.php";
?>

	<div id="content">
			
		<form name="form_region_edit" id="form_region_edit" method="post" enctype='application/x-www-form-urlencoded' accept-charset="UTF-8" class="form">