insert_submit_name;
$submitvalue = "e n t e r c a t e g o r y";
break;
case 'edit':
$submitname = $this->edit_submit_name;
$submitvalue = "s u b m i t c h a n g e s";
break;
} // switch
$this->fields = array(
'name' => array(
'label' => 'Name',
'label_css' => 'black_11_bold',
'type' => array(
'tag'=> 'input_text',
'input_size' => 30,
'char_max' => 255
),
'validation' => array('required')
),
'status_web' => array(
'label' => 'Web Status',
'label_css' => 'black_11_bold',
'type' => array(
'tag' => 'select',
'options' => array('active'=>'active','inactive'=>'inactive'),
'top_option' => array(),
),
'validation' => array('required'),
'default' => 'inactive'
),
'name_image' => array(
'label' => 'Vertical Name Image',
'label_css' => 'black_11_bold',
'type' => array(
'tag' => 'input_file'
)
),
$submitname => array(
'type' => array(
'tag'=> 'input_submit',
),
'input_css' => 'blue_submit',
'default' => $submitvalue,
)
);
if($form_type == 'edit' && isset($db_fields['name_image']) && $db_fields['name_image'] != '')
{
// show the pic
$this->fields['name_image']['html_before'] = '
replace: ';
}
if($db_default)
{
foreach($this->fields as $fieldName=>$fieldInfo)
{
$exclude_fields = array();
if(!in_array($fieldName, $exclude_fields) && $fieldInfo['type']['tag'] != 'input_submit' && $fieldInfo['type']['tag'] != 'input_hidden')
{
$default = $db_fields[$fieldName];
$this->fields[$fieldName]['default'] = $default;
}
}
}
}
function _validate($CategoryForm, $category_id='')
{
// unique validation for this page
// category name must be unique
$name = trim($CategoryForm->get_field_value('name'));
if($name != '')
{
$name_sel = "SELECT * FROM ".Config::$db_tables['inventory_categories']." WHERE name = '".addslashes($name)."'";
if($category_id != '')
{
// for edits don't validate against itself for uniqueness
$name_sel .= "AND id != '".$category_id."'";
}
if(Database::ado_get_row($name_sel))
{
$CategoryForm->set_field_error('name', 'already exists');
$CategoryForm->set_error(TRUE);
return(FALSE);
}
}
}
} // class
?>