venus /fuel/packages/oil/views/scaffolding/orm/actions/edit.php

Language PHP Lines 42
MD5 Hash ed23839309254a1bd1c253172b2c73ee Estimated Cost $352 (why?)
Repository https://bitbucket.org/arkross/venus View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
		is_null($id) and Response::redirect('<?php echo $controller_name ?>');

		$<?php echo $singular_name; ?> = Model_<?php echo $model_name; ?>::find($id);

		$val = Model_<?php echo $model_name; ?>::validate('edit');

		if ($val->run())
		{
<?php foreach ($fields as $field): ?>
			$<?php echo $singular_name; ?>-><?php echo $field['name']; ?> = Input::post('<?php echo $field['name']; ?>');
<?php endforeach; ?>

			if ($<?php echo $singular_name; ?>->save())
			{
				Session::set_flash('success', 'Updated <?php echo $singular_name; ?> #' . $id);

				Response::redirect('<?php echo $uri; ?>');
			}

			else
			{
				Session::set_flash('error', 'Could not update <?php echo $singular_name; ?> #' . $id);
			}
		}

		else
		{
			if (Input::method() == 'POST')
			{
<?php foreach ($fields as $field): ?>
				$<?php echo $singular_name; ?>-><?php echo $field['name']; ?> = $val->validated('<?php echo $field['name']; ?>');
<?php endforeach; ?>

				Session::set_flash('error', $val->show_errors());
			}

			$this->template->set_global('<?php echo $singular_name; ?>', $<?php echo $singular_name; ?>, false);
		}

		$this->template->title = "<?php echo ucfirst($plural_name); ?>";
		$this->template->content = View::forge('<?php echo $view_path; ?>/edit');
Back to Top