Просмотр исходного кода

Add project ID check for overrides section

Alan Lam 8 лет назад
Родитель
Сommit
b6becc9dea
1 измененных файлов с 49 добавлено и 44 удалено
  1. 49 44
      views/project_form.php

+ 49 - 44
views/project_form.php

@@ -184,58 +184,63 @@ $time_of_day_options = [
 			</div>
 		</div>
 
-		<hr />
+		<?php
+		if($project->id) {
+			?>
+			<hr />
 
-		<div class="row">
-			<div class="col">
-				<h3>Template Overrides</h3>
-			</div>
-			<div class="col-auto">
-				<a class="btn btn-outline-primary" href="/account/projects/<?=$project->id?>/edit/template-overrides">Edit</a>
+			<div class="row">
+				<div class="col">
+					<h3>Template Overrides</h3>
+				</div>
+				<div class="col-auto">
+					<a class="btn btn-outline-primary" href="/account/projects/<?=$project->id?>/edit/template-overrides">Edit</a>
+				</div>
 			</div>
-		</div>
 
-		<?php
-		$overrides = $project->getTemplateOverrides();
-		if(empty($overrides)) {
-			?>
-			<div class="alert alert-info">There are no template overrides configured for this project.</div>
 			<?php
-		}
-		else {
-			$fields = $template->getFields();
-			?>
-			<table class="table table-bordered table-hover">
-				<thead>
-					<tr>
-						<th>Field</th>
-						<th>Element</th>
-						<th>Value</th>
-					</tr>
-				</thead>
-				<tbody>
+			$overrides = $project->getTemplateOverrides();
+			if(empty($overrides)) {
+				?>
+				<div class="alert alert-info">There are no template overrides configured for this project.</div>
 				<?php
-				foreach($overrides as $override) {
-					?>
-					<tr>
-						<td>
-							<?=htmlspecialchars($fields[$override->field]->label)?>
-						</td>
-						<td>
-							<?=ucfirst($override->element)?>
-						</td>
-						<td>
-							<?=htmlspecialchars($override->value)?>
-						</td>
-					</tr>
-					<?php
-				}
+			}
+			else {
+				$fields = $template->getFields();
 				?>
-				</tbody>
-			</table>
-			<?php
+				<table class="table table-bordered table-hover">
+					<thead>
+						<tr>
+							<th>Field</th>
+							<th>Element</th>
+							<th>Value</th>
+						</tr>
+					</thead>
+					<tbody>
+					<?php
+					foreach($overrides as $override) {
+						?>
+						<tr>
+							<td>
+								<?=htmlspecialchars($fields[$override->field]->label)?>
+							</td>
+							<td>
+								<?=ucfirst($override->element)?>
+							</td>
+							<td>
+								<?=htmlspecialchars($override->value)?>
+							</td>
+						</tr>
+						<?php
+					}
+					?>
+					</tbody>
+				</table>
+				<?php
+			}
 		}
 		?>
+
 		<hr />
 
 		<input type="hidden" name="location_ids" id="location-ids" value="<?=implode(", ", $location_ids)?>" />