.mylink::after{
display:inline-block;
content:'';
width: 10px;
height: 5px;
background: url('ПУТЬ К ТВОЕЙ КАРТИНКЕ') no-repeat;
}
$this->registerJs(
<<<JS
$('form').on('beforeSubmit',function(event) {
var yiiForm = $(this);
yiiForm.find('.has-error').removeClass('has-error');
yiiForm.find('.help-block').html('');
$.ajax({
url: yiiForm.attr('action'),
type: 'post',
data: yiiForm.serialize(),
success: function(result) {
if(result.errors) {
jQuery.each(result.errors, function(id, error) {
$('.field-' + id).addClass('has-error').find('.help-block').html(error);
});
}
if(result.status == true){
// show message
}
}
});
return false;
});
JS
);
/**
* Parsing xml file according to $key_node
*
* @param $key_node
* @param null $filePath
*
* @return array|bool
*/
public function parseXml($key_node, $filePath = null)
{
try {
$output = [];
$DOMDocument = new DOMDocument();
$reader = new XMLReader();
$reader->open($filePath);
$line = 0;
while (($read = $reader->read()) && $reader->name !== $key_node) {
$line++;
}
if (!$read) {
$text = "Не возможно прочитать xml файл - {$filePath}<br>";
$text .= "Элемент - {$key_node} отсутствует в файле<br>";
$this->importErrorText = $text;
return $output = [];
}
$i = 0;
while ($reader->name === $key_node) {
try {
$expanded = $reader->expand();
} catch (Exception $e) {
$this->readImportFileErrors[] = $e->getMessage();
try {
$reader->next($key_node);
} catch (Exception $e) {
$this->readImportFileErrors[] = $e->getMessage();
}
}
if (isset($expanded) && $expanded) {
if ($expanded->attributes) {
$dom = simplexml_import_dom($DOMDocument->importNode($expanded, true));
foreach ($dom->attributes() as $k => $v) {
$fieldName = mb_convert_encoding(trim($k), 'utf-8');
$output[$i][$fieldName] = mb_convert_encoding(trim((string)$v),
'utf-8');
$output[$i]['title'] = mb_convert_encoding(trim((string)$expanded->nodeValue), 'utf-8');
};
}
foreach ($expanded->childNodes as $k => $item) {
if ($item->nodeType == 1) {
if ($item->attributes->length > 0) {
foreach ($item->attributes as $prop) {
if ((string)$prop->nodeValue) {
$fieldName = trim((string)$item->nodeName);
$output[$i][$fieldName][trim((string)$prop->nodeValue)] = mb_convert_encoding(trim((string)$item->nodeValue),
'utf-8');
}
}
} else {
$nodeName = trim((string)$item->nodeName);
if (in_array($nodeName, ['picture', 'image'])) {
$output[$i]['image'][] = mb_convert_encoding(trim((string)$item->nodeValue),
'utf-8');
} else {
$output[$i][$nodeName] = mb_convert_encoding(trim((string)$item->nodeValue),
'utf-8');
}
}
}
}
if (!isset($output[$i]['code']) && !isset($output[$i]['vendorCode']) && !isset($output[$i]['barcode'])) {
$article = ArrayHelper::getValue($output[$i], 'param.Артикул');
if ($article) {
$output[$i]['article'] = $article;
}
}
}
try {
$reader->next($key_node);
} catch (Exception $e) {
$this->readImportFileErrors[] = $e->getMessage();
}
$i++;
}
return $output;
} catch (Exception $exception) {
$this->importErrorText = 'Ошибка чтения файла';
return [];
}
}
$(document).ready(function() {
$('#payform').on('submit', e => {
let form = $('#payform');
e.preventDefault();
let url = form.attr('action');
let data = form.serialize();
$.post(url, data, response => {
console.log(response);
})
return false;
})
});