added nicer overview and delete function
This commit is contained in:
@ -57,9 +57,13 @@ class Model {
|
||||
|
||||
public function save()
|
||||
{
|
||||
$newgen = false;
|
||||
if (!$this->id)
|
||||
{
|
||||
$this->id = gen_ulid();
|
||||
if (!$this->validate())
|
||||
$newgen = true;
|
||||
}
|
||||
if (!$this->validate($newgen))
|
||||
return false;
|
||||
foreach($this->dbFields as $field=>$options)
|
||||
{
|
||||
@ -111,7 +115,7 @@ class Model {
|
||||
/**
|
||||
* @param array $data
|
||||
*/
|
||||
private function validate()
|
||||
private function validate($newgen=false)
|
||||
{
|
||||
if (!$this->dbFields)
|
||||
return true;
|
||||
@ -133,8 +137,8 @@ class Model {
|
||||
if (is_array($value))
|
||||
continue;
|
||||
|
||||
if (isset($desc[0]))
|
||||
$type = $desc[0];
|
||||
// if (isset($desc[0]))
|
||||
// $type = $desc[0];
|
||||
if (in_array('required',$options))
|
||||
$required = true;
|
||||
|
||||
@ -149,8 +153,11 @@ class Model {
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
if($options['default']!==null && $value===null)
|
||||
if($options['default']!==null && $newgen === true && !$value)
|
||||
{
|
||||
$value = $options['default'];
|
||||
$this->data[$key] = $value;
|
||||
}
|
||||
|
||||
if ($required && strlen($value) == 0) {
|
||||
throw new Exception($this->dbTable . "." . $key . " is required");
|
||||
|
@ -47,7 +47,7 @@ class Page
|
||||
$this->menu_priority = 1;
|
||||
}
|
||||
|
||||
function addSubmenuItem($text, $action, $icon = '', $classes = '')
|
||||
function addSubmenuItem($text, $action='', $icon = '', $classes = '')
|
||||
{
|
||||
$active = $GLOBALS['url'][0];
|
||||
if (!$active) $active = 'index';
|
||||
|
Reference in New Issue
Block a user