class OrganizationsSearch extends Organizations
{
public $parent_short_name;
/**
* @inheritdoc
*/
public function rules()
{
return [
[['parent_short_name'], 'string'],
// other rules
];
}
public function search($params)
{
$query = Organizations::find();
$query->alias('org');
$dataProvider = new ActiveDataProvider([
'query' => $query,
]);
$query->joinWith(['parentOrganization' => function($q) {
/**
* @var ActiveQuery $q
*/
$q->alias('par_org');
}]);
$this->load($params);
$dataProvider->setSort([
'attributes' => [
'parent_short_name' => [
'asc' => ['par_org.short_name' => SORT_ASC],
'desc' => ['par_org.short_name' => SORT_DESC],
],
// other attributes
],
'defaultOrder' => [
// defaultOrders
],
]);
if (!$this->validate()) {
return $dataProvider;
}
$query->andFilterWhere(['ilike', 'org.short_name', $this->short_name]);
$query->andFilterWhere(['ilike', 'par_org.short_name', $this->parent_short_name]);
return $dataProvider;
}
}
'attribute' => 'parent_short_name',
$dhb->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
$(document).on('beforeSubmit', '#my-form', function () {
var _this = $(this);
$.ajax({
url: _this.attr('action'),
data: _this.serialize(),
type: 'POST',
dataType: 'json',
success: function (response) {
if (response.success) {
$.pjax.reload({
container: "#my-pjax-container-id"
});
} else {
// alert
}
},
error: function (jqXHR, textStatus, errorThrown) {
console.info(textStatus + ' ' + errorThrown);
}
});
return false;
});
SetEnv TZ Europe/Moscow
php_value date.timezone 'Europe/Moscow'
$('from [name="address"]').keyup(function(){
if($(this).val().toLowerCase().indexOf('москва') > -1) {
$('form select').html('<option>1</option><option>2</option>');
}
});
но в БД записывается одно и то же значение (2498) во все поля.
if(isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest') {
echo json_encode($arr);
exit;
}
echo '
<script>
if ( in_array(this.value, ["'.implode('","', $emails).'"]) ) {
this.setCustomValidity("' . esc_html__('This email already exists','fashionpress') . '");
}
</script>
';