Доброе люди, пожалуйста помогите найти ошибку. На примере других форм сделал свое.
Это форм, который находится в файле "catalog/view/theme/my_theme_name/template/productproduct.twig"
<form class="form-horizontal" enctype="multipart/form-data" id="form-kredit">
<div id="kredits"></div>
<div class="form-group">
<label class="control-label col-sm-2" for="myname">First Name:</label>
<div class="col-sm-10">
<input type="text" class="form-control" id="myname" placeholder="Enter Name" name="myname">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<button type="button" id="submit_kredit" data-loading-text="{{ text_loading }}" class="btn btn-primary">{{ button_continue }}</button>
</div>
</div>
</form>
Это Ajax, находится в том же файле"catalog/view/theme/my_theme_name/template/productproduct.twig"
$('#kredits').delegate('.pagination a', 'click', function(e) {
e.preventDefault();
$('#kredits').fadeOut('slow');
$('#kredits').load(this.href);
$('#kredits').fadeIn('slow');
});
$('#kredits').load('index.php?route=product/product/kredit&product_id={{ product_id }}');
$('#submit_kredit').on('click', function() {
$.ajax({
url: 'index.php?route=product/product/kredits&product_id={{ product_id }}',
type: 'post',
dataType: 'json',
data: $("#form-kredit").serialize(),
beforeSend: function() {
$('#submit_kredit').button('loading');
},
complete: function() {
$('#submit_kredit').button('reset');
},
success: function(json) {
$('.alert-dismissible').remove();
if (json['error']) {
$('#kredits').after('<div class="alert alert-danger alert-dismissible"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + '</div>');
}
if (json['success']) {
$('#kredits').after('<div class="alert alert-success alert-dismissible"><i class="fa fa-check-circle"></i> ' + json['success'] + '</div>');
$('input[name=\'myname\']').val('');
}
}
});
});
Это контроллер "catalog/controller/product/product.php"
public function kredit() {
$this->load->language('product/product');
$json = array();
if ($this->request->server['REQUEST_METHOD'] == 'POST') {
if (utf8_strlen($this->request->post['myname'])) {
$json['error'] = $this->language->get('error_name');
}
if (!isset($json['error'])) {
$this->load->model('catalog/kredit');
$this->model_catalog_kredit->addKredit($this->request->get['product_id'], $this->request->post);
$json['success'] = $this->language->get('text_success');
}
}
$this->response->addHeader('Content-Type: application/json');
$this->response->setOutput(json_encode($json));
}
А это часть модели файл находится в "catalog/model/catalog/kredit.php"
<?php
class ModelCatalogKredit extends Model {
public function addKredit($product_id, $data)
{
$this->db->query("UPDATE " . DB_PREFIX . "product SET kredit_status = 1 where product_id = '" . (int)$product_id . "'");
}
}
Создать в бд колумн и хочу его обновить и этим проверить правильно ли построил.Но не обновляется, к тому же выводится ошибка что минимум 3 буквы и макс 25, хотя у меня не стоят такие ограничение. Доброе люди, пожалуйста помогите.