Passed
Push — develop ( 319bd8...330c7a )
by Neill
16:41 queued 15s
created
neon/phoebe/plugins/smarty/function.ddsForm.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -148,7 +148,7 @@  discard block
 block discarded – undo
148 148
 
149 149
 	// process the parameters
150 150
 	if (!isset($params['classType']))
151
-		throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true));
151
+		throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params, true));
152 152
 	$classType = $params['classType'];
153 153
 	$cssClass = isset($params['cssClass']) ? $params['cssClass'] : null;
154 154
 	$label = isset($params['label']) ? $params['label'] : null;
@@ -160,12 +160,12 @@  discard block
 block discarded – undo
160 160
 	$assignSaved = !empty($params['assignSaved']) ? $params['assignSaved'] : 'saved';
161 161
 	$assignErrors = !empty($params['assignErrors']) ? $params['assignErrors'] : 'errors';
162 162
 	$assignSubmitted = !empty($params['assignSubmitted']) ? $params['assignSubmitted'] : 'submitted';
163
-	$readOnly = isset($params['readOnly']) ? (bool)$params['readOnly'] : false;
164
-	$printOnly = isset($params['printOnly']) ? (bool)$params['printOnly'] : false;
163
+	$readOnly = isset($params['readOnly']) ? (bool) $params['readOnly'] : false;
164
+	$printOnly = isset($params['printOnly']) ? (bool) $params['printOnly'] : false;
165 165
 	$uuid = !empty($params['uuid']) ? $params['uuid'] : null;
166 166
 	$dataSources = !empty($params['dataSources']) ? $params['dataSources'] : null;
167
-	$enableAjaxValidation = isset($params['enableAjaxValidation']) ? (bool)$params['enableAjaxValidation'] : true;
168
-	$enableAjaxSubmission = isset($params['enableAjaxSubmission']) ? (bool)$params['enableAjaxSubmission'] : false;
167
+	$enableAjaxValidation = isset($params['enableAjaxValidation']) ? (bool) $params['enableAjaxValidation'] : true;
168
+	$enableAjaxSubmission = isset($params['enableAjaxSubmission']) ? (bool) $params['enableAjaxSubmission'] : false;
169 169
 	$ajaxValidationUrl = !empty($params['ajaxValidationUrl']) ? $params['ajaxValidationUrl'] : '/phoebe/database/index/validate-form';
170 170
 	$returnUrl = !empty($params['returnUrl']) ? $params['returnUrl'] : null;
171 171
 	$formName = !empty($params['name']) ? $params['name'] : null;
@@ -178,7 +178,7 @@  discard block
 block discarded – undo
178 178
 	$id = ($id ? $id : ($uuid ? $uuid : null));
179 179
 	if ($id) {
180 180
 		if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_')
181
-			$id = 'z' . $id;
181
+			$id = 'z'.$id;
182 182
 	}
183 183
 	$changeLogUuids = [];
184 184
 
@@ -249,7 +249,7 @@  discard block
 block discarded – undo
249 249
 
250 250
 	// assign all of the save results to the template
251 251
 	foreach ($saveFormResults as $k=>$v)
252
-		$template->assign($k,$v);
252
+		$template->assign($k, $v);
253 253
 
254 254
 
255 255
 	// assign the resulting form
Please login to merge, or discard this patch.
Braces   +9 added lines, -6 removed lines patch added patch discarded remove patch
@@ -147,8 +147,9 @@  discard block
 block discarded – undo
147 147
 	$phoebeType = 'daedalus';
148 148
 
149 149
 	// process the parameters
150
-	if (!isset($params['classType']))
151
-		throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true));
150
+	if (!isset($params['classType'])) {
151
+			throw new \RuntimeException("You must pass in the form's classType otherwise we don't which form it is. You passed in: ".print_r($params,true));
152
+	}
152 153
 	$classType = $params['classType'];
153 154
 	$cssClass = isset($params['cssClass']) ? $params['cssClass'] : null;
154 155
 	$label = isset($params['label']) ? $params['label'] : null;
@@ -177,8 +178,9 @@  discard block
 block discarded – undo
177 178
 	// prefix invalid (HTML5) ids with a letter
178 179
 	$id = ($id ? $id : ($uuid ? $uuid : null));
179 180
 	if ($id) {
180
-		if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_')
181
-			$id = 'z' . $id;
181
+		if (is_numeric($id[0]) || $id[0] == '-' || $id[0] == '_') {
182
+					$id = 'z' . $id;
183
+		}
182 184
 	}
183 185
 	$changeLogUuids = [];
184 186
 
@@ -248,8 +250,9 @@  discard block
 block discarded – undo
248 250
 	}
249 251
 
250 252
 	// assign all of the save results to the template
251
-	foreach ($saveFormResults as $k=>$v)
252
-		$template->assign($k,$v);
253
+	foreach ($saveFormResults as $k=>$v) {
254
+			$template->assign($k,$v);
255
+	}
253 256
 
254 257
 
255 258
 	// assign the resulting form
Please login to merge, or discard this patch.
neon/phoebe/App.php 1 patch
Braces   +60 added lines, -40 removed lines patch added patch discarded remove patch
@@ -252,16 +252,18 @@  discard block
 block discarded – undo
252 252
 		$formDefinition = [];
253 253
 		if (!empty($options['uuid'])) {
254 254
 			$object = $phoebe->getObject($options['uuid']);
255
-			if (!$object)
256
-				throw new \RuntimeException('The requested form object was not found. Uuid='.$options['uuid']);
255
+			if (!$object) {
256
+							throw new \RuntimeException('The requested form object was not found. Uuid='.$options['uuid']);
257
+			}
257 258
 			$class = $object->getIPhoebeClass();
258 259
 			$formDefinition = $class->getClassFormDefinition($fields);
259 260
 		} else {
260 261
 			// otherwise get a clean class
261 262
 			if ($classType) {
262 263
 				$formDefinition = $this->getFormDefinition($phoebeType, $classType, $fields);
263
-				if (!count($formDefinition))
264
-					throw new \RuntimeException('The requested form type was not found. Type='.$classType);
264
+				if (!count($formDefinition)) {
265
+									throw new \RuntimeException('The requested form type was not found. Type='.$classType);
266
+				}
265 267
 			}
266 268
 		}
267 269
 		$fieldCount = count($formDefinition['fields']);
@@ -269,16 +271,19 @@  discard block
 block discarded – undo
269 271
 
270 272
 
271 273
 		// temporary code to cover problems with differences between appForms and ddsForms
272
-		if ($phoebeType !== 'applicationForm' && !empty($options['initialiseFromDds']))
273
-			throw new \RuntimeException('Only applicationForms work with initialiseFromDds');
274
+		if ($phoebeType !== 'applicationForm' && !empty($options['initialiseFromDds'])) {
275
+					throw new \RuntimeException('Only applicationForms work with initialiseFromDds');
276
+		}
274 277
 
275 278
 		// set the form class
276
-		if (!empty($options['cssClass']))
277
-			$form->setAttributes(['class'=>$options['cssClass']]);
279
+		if (!empty($options['cssClass'])) {
280
+					$form->setAttributes(['class'=>$options['cssClass']]);
281
+		}
278 282
 
279 283
 		// set the form id
280
-		if (!empty($options['id']))
281
-			$form->setId($options['id']);
284
+		if (!empty($options['id'])) {
285
+					$form->setId($options['id']);
286
+		}
282 287
 		$formId = $form->getId();
283 288
 		if ($printOnly) {
284 289
 			$form->printOnly = true;
@@ -289,17 +294,20 @@  discard block
 block discarded – undo
289 294
 		}
290 295
 
291 296
 		// set the forms label - allow clearing of it via empty string
292
-		if (isset($options['label']))
293
-			$form->setLabel($options['label']);
297
+		if (isset($options['label'])) {
298
+					$form->setLabel($options['label']);
299
+		}
294 300
 
295 301
 
296 302
 		// check to see if we are not posting from the client, populate it from the database
297 303
 		// !set the form name before checking data set!
298
-		if (!empty($options['name']))
299
-			$form->setName($options['name']);
304
+		if (!empty($options['name'])) {
305
+					$form->setName($options['name']);
306
+		}
300 307
 		if (!empty($options['initialiseFromDds']) && (!$object || !$object->data)) {
301
-			if (!$object)
302
-				$object = $phoebe->createStubObject($classType);
308
+			if (!$object) {
309
+							$object = $phoebe->createStubObject($classType);
310
+			}
303 311
 			$object->initialiseFromDds($options['initialiseFromDds']);
304 312
 		}
305 313
 		if ($object && !$form->hasRequestData()) {
@@ -307,8 +315,9 @@  discard block
 block discarded – undo
307 315
 		}
308 316
 
309 317
 		if (!($printOnly || $readOnly)) {
310
-			if (!empty($options['uuid']))
311
-				$form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaUuidString}", ['value'=>$options['uuid']]);
318
+			if (!empty($options['uuid'])) {
319
+							$form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaUuidString}", ['value'=>$options['uuid']]);
320
+			}
312 321
 
313 322
 			// set any additional data sources
314 323
 			if (!empty($options['dataSources'])) {
@@ -316,8 +325,9 @@  discard block
 block discarded – undo
316 325
 					$form->addFieldHidden("{$this->formMetaPrefix}{$this->formMetaDataSourceString}$key", ['value'=>$value]);
317 326
 					// for dds forms, set the values on the form too for initial display
318 327
 					if ($phoebeType == 'daedalus') {
319
-						if ($form->hasField($key))
320
-							$form->getField($key)->setValue($value);
328
+						if ($form->hasField($key)) {
329
+													$form->getField($key)->setValue($value);
330
+						}
321 331
 					}
322 332
 				}
323 333
 			}
@@ -328,8 +338,9 @@  discard block
 block discarded – undo
328 338
 			if (!empty($options['mapFilters'])) {
329 339
 				foreach ($options['mapFilters'] as $key=>$filters) {
330 340
 					$f = $form->getField($key);
331
-					if ($f && isset($f->dataMapFilters))
332
-						$f->dataMapFilters = $filters;
341
+					if ($f && isset($f->dataMapFilters)) {
342
+											$f->dataMapFilters = $filters;
343
+					}
333 344
 				}
334 345
 			}
335 346
 
@@ -339,8 +350,9 @@  discard block
 block discarded – undo
339 350
 			if (!empty($options['mapFields'])) {
340 351
 				foreach ($options['mapFields'] as $key=>$mapFields) {
341 352
 					$f = $form->getField($key);
342
-					if ($f && isset($f->dataMapFields))
343
-						$f->dataMapFields = $mapFields;
353
+					if ($f && isset($f->dataMapFields)) {
354
+											$f->dataMapFields = $mapFields;
355
+					}
344 356
 				}
345 357
 			}
346 358
 
@@ -365,20 +377,24 @@  discard block
 block discarded – undo
365 377
 			}
366 378
 
367 379
 			// set the forms action
368
-			if (!empty($options['action']))
369
-				$form->setAction($options['action']);
380
+			if (!empty($options['action'])) {
381
+							$form->setAction($options['action']);
382
+			}
370 383
 
371 384
 			// set whether or not ajax validation is required
372
-			if (isset($options['enableAjaxValidation']))
373
-				$form->enableAjaxValidation = (boolean) $options['enableAjaxValidation'];
385
+			if (isset($options['enableAjaxValidation'])) {
386
+							$form->enableAjaxValidation = (boolean) $options['enableAjaxValidation'];
387
+			}
374 388
 
375 389
 			// set whether or not ajax submission is required
376
-			if (isset($options['enableAjaxSubmission']))
377
-				$form->enableAjaxSubmission = (boolean) $options['enableAjaxSubmission'];
390
+			if (isset($options['enableAjaxSubmission'])) {
391
+							$form->enableAjaxSubmission = (boolean) $options['enableAjaxSubmission'];
392
+			}
378 393
 
379 394
 			// set where the form will check itself via ajaxValidation
380
-			if (!empty($options['ajaxValidationUrl']))
381
-				$form->validationUrl = $options['ajaxValidationUrl'];
395
+			if (!empty($options['ajaxValidationUrl'])) {
396
+							$form->validationUrl = $options['ajaxValidationUrl'];
397
+			}
382 398
 
383 399
 			// set where the browser will go to after completion of the form
384 400
 			if (!empty($options['returnUrl'])) {
@@ -438,8 +454,9 @@  discard block
 block discarded – undo
438 454
 			$definition = $this->getFormDefinition($phoebeType, $classType);
439 455
 			$form = new \neon\core\form\Form($definition);
440 456
 		}
441
-		if (!empty($formName))
442
-			$form->setName($formName);
457
+		if (!empty($formName)) {
458
+					$form->setName($formName);
459
+		}
443 460
 		if ($form->processRequest()) {
444 461
 			$data = $form->getData();
445 462
 			// prevent multiple renders resulting in multiple saves of the form
@@ -461,13 +478,15 @@  discard block
 block discarded – undo
461 478
 					$changeLogUuids['add'] = $object->getChangeLogUuid();
462 479
 				}
463 480
 				$uuid = $object->uuid;
464
-				if (!empty($meta['dataSources']))
465
-					$object->setDataSources($meta['dataSources']);
481
+				if (!empty($meta['dataSources'])) {
482
+									$object->setDataSources($meta['dataSources']);
483
+				}
466 484
 				if ($object->editObject($data) === true) {
467 485
 					$alreadySubmitted[$submittedCheck] = $uuid;
468 486
 					$changeLogUuids['edit'] = $object->getChangeLogUuid();
469
-					if (!empty($meta['returnUrl']))
470
-						neon()->response->redirect(html_entity_decode($meta['returnUrl']));
487
+					if (!empty($meta['returnUrl'])) {
488
+											neon()->response->redirect(html_entity_decode($meta['returnUrl']));
489
+					}
471 490
 					return true;
472 491
 				}
473 492
 			} else {
@@ -512,8 +531,9 @@  discard block
 block discarded – undo
512 531
 					$meta['uuid'] = $v;
513 532
 				} else if (strpos($key, $this->formMetaDataSourceString) === 0) {
514 533
 					$itemKey = substr($key, strlen($this->formMetaDataSourceString));
515
-					if (empty($meta['dataSources'][$itemKey]))
516
-						$meta['dataSources'][$itemKey] = $v;
534
+					if (empty($meta['dataSources'][$itemKey])) {
535
+											$meta['dataSources'][$itemKey] = $v;
536
+					}
517 537
 				} else if ($key==$this->formMetaReturnUrlString && empty($meta['returnUrl'])) {
518 538
 					$meta['returnUrl'] = $v;
519 539
 				}
Please login to merge, or discard this patch.