1
I picked up an example on github and I’m trying to put images on the products,
I created a input[type="file"]
and this returning me this mistake.
Error: Form elements must not be named "submit".
But if I put the input[type="text"]
makes normal registration in BD.
php form.
<div id="required_fields_message"><?php echo $this->lang->line('common_fields_required_message'); ?></div>
<ul id="error_message_box"></ul>
<?php
echo form_open('items/save/'.$item_info->item_id,array('id'=>'item_form'));
?>
<fieldset id="item_basic_info">
<legend><?php echo $this->lang->line("items_basic_information"); ?></legend>
<div class="form-group row">
<label class="col-sm-4 col-form-label"><?php echo form_label($this->lang->line('items_name').':', 'name',array('class'=>'required wide')); ?></label>
<div class='col-sm-8'>
<?php echo form_input(array(
'class'=>'form-control',
'name'=>'name',
'id'=>'name',
'value'=>$item_info->name)
);?>
</div>
</div>
<div class="form-group">
<label>Foto</label>
<input type="file" class="form-control-file" id="img1" name="img1">
</div>
<?php
echo form_submit(array(
'name'=>'submit',
'id'=>'submit',
'value'=>$this->lang->line('common_submit'),
'class'=>'submit_button float_right')
);
?>
</fieldset>
<?php
echo form_close();
?>
items.php
function save($item_id=-1)
{
$item_data = array(
'name'=>$this->input->post('name'),
'description'=>$this->input->post('description'),
'category'=>$this->input->post('category'),
'supplier_id'=>$this->input->post('supplier_id')=='' ? null:$this->input->post('supplier_id'),
'item_number'=>$this->input->post('item_number')=='' ? null:$this->input->post('item_number'),
'cost_price'=>$this->input->post('cost_price'),
'unit_price'=>$this->input->post('unit_price'),
'quantity'=>$this->input->post('quantity'),
'reorder_level'=>$this->input->post('reorder_level'),
'location'=>$this->input->post('location'),
'allow_alt_description'=>$this->input->post('allow_alt_description'),
'is_serialized'=>$this->input->post('is_serialized')
);
$employee_id=$this->Employee->get_logged_in_employee_info()->person_id;
$cur_item_info = $this->Item->get_info($item_id);
if($this->Item->save($item_data,$item_id))
{
//New item
if($item_id==-1)
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_adding').' '.
$item_data['name'],'item_id'=>$item_data['item_id']));
$item_id = $item_data['item_id'];
}
else //previous item
{
echo json_encode(array('success'=>true,'message'=>$this->lang->line('items_successful_updating').' '.
$item_data['name'],'item_id'=>$item_id));
}
$inv_data = array
(
'trans_date'=>date('Y-m-d H:i:s'),
'trans_items'=>$item_id,
'trans_user'=>$employee_id,
'trans_comment'=>$this->lang->line('items_manually_editing_of_quantity'),
'trans_inventory'=>$cur_item_info ? $this->input->post('quantity') - $cur_item_info->quantity : $this->input->post('quantity')
);
$this->Inventory->insert($inv_data);
$items_taxes_data = array();
$tax_names = $this->input->post('tax_names');
$tax_percents = $this->input->post('tax_percents');
for($k=0;$k<count($tax_percents);$k++)
{
if (is_numeric($tax_percents[$k]))
{
$items_taxes_data[] = array('name'=>$tax_names[$k], 'percent'=>$tax_percents[$k] );
}
}
$this->Item_taxes->save($items_taxes_data, $item_id);
}
else//failure
{
echo json_encode(array('success'=>false,'message'=>$this->lang->line('items_error_adding_updating').' '.
$item_data['name'],'item_id'=>-1));
}
}