forked from bmidget/kohana-formo
-
Notifications
You must be signed in to change notification settings - Fork 1
/
core.php
66 lines (52 loc) · 1.32 KB
/
core.php
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php defined('SYSPATH') or die('No direct script access.');
abstract class Formo_Driver_Core {
// The field or form object
protected $field;
protected $view;
public static function factory(Container $field)
{
return new Formo_Driver($field);
}
public function __construct(Container $field)
{
$this->field = $field;
}
// Call the function on the $this->field
public function __call($method, $args)
{
return call_user_func_array(array($this->field, $method), $args);
}
public function __set($variable, $value)
{
$this->field->$variable = $value;
}
public function __get($variable)
{
return $this->field->$variable;
}
public function view()
{
$prefix = $this->parent(CONTAINER::PARENT)->get('view_prefix');
$view = $this->get('view') ? $this->get('view') : $this->view;
return $prefix.$this->get('render_type').'/'.$view;
}
public function val($value)
{
$this->field->defaults('value', $value);
if ($model = $this->field->model())
{
$model->{$this->field->alias()} = $value;
}
}
public function pre_render()
{
foreach ($this->field->get_validator('post_filters') as $filter)
{
// Execute every post filter
$filter->execute();
}
}
public function pre_render_json($field){}
public function pre_render_html($field){}
public function pre_render_xml($field){}
}