Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskonsite-архив-перенесен
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Packages
Packages
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Dmitry Korolev
taskonsite-архив-перенесен
Commits
69d8d25c
Commit
69d8d25c
authored
Feb 05, 2016
by
Олег Гиммельшпах
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of git.task-on.com:ktask/task-on.com
parents
9066a938
ac08a4b4
Changes
16
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
1485 additions
and
36 deletions
+1485
-36
common/components/BaseForm.php
common/components/BaseForm.php
+11
-2
common/components/_BaseForm.php
common/components/_BaseForm.php
+2
-1
common/modules/rbac/models/AuthItem.php
common/modules/rbac/models/AuthItem.php
+3
-3
common/modules/school/controllers/CourseController.php
common/modules/school/controllers/CourseController.php
+4
-1
common/modules/school/models/Courses.php
common/modules/school/models/Courses.php
+0
-1
common/modules/school/views/course/index.php
common/modules/school/views/course/index.php
+3
-6
common/modules/users/controllers/UserController.php
common/modules/users/controllers/UserController.php
+5
-4
common/modules/users/forms/RegistrationUserForm.php
common/modules/users/forms/RegistrationUserForm.php
+44
-0
common/modules/users/models/User.php
common/modules/users/models/User.php
+30
-10
console/migrations/m160204_213447_add_field_to_users_table.php
...le/migrations/m160204_213447_add_field_to_users_table.php
+17
-0
frontend/config/main.php
frontend/config/main.php
+5
-3
frontend/controllers/SiteController.php
frontend/controllers/SiteController.php
+11
-2
frontend/views/layouts/foot.php
frontend/views/layouts/foot.php
+3
-2
frontend/web/css/screen.css
frontend/web/css/screen.css
+6
-0
frontend/web/js/common.js
frontend/web/js/common.js
+64
-1
frontend/web/js/jquery.form.js
frontend/web/js/jquery.form.js
+1277
-0
No files found.
common/components/BaseForm.php
View file @
69d8d25c
...
...
@@ -168,6 +168,10 @@ JS;
$opt
=
$element
[
'fileOptions'
];
if
(
!
empty
(
$element
[
'empty'
]))
$opt
[
'value'
]
=
$element
[
'empty'
];
if
(
!
empty
(
$element
[
'inputOptions'
]))
$optEl
[
'inputOptions'
]
=
$element
[
'inputOptions'
];
if
(
!
empty
(
$element
[
'inputOptions'
]))
$opt
[
'inputOptions'
]
=
$element
[
'inputOptions'
];
switch
(
$element
[
'type'
])
{
case
'checkbox'
:
$opt
[
'data-render'
]
=
'switchery'
;
...
...
@@ -191,12 +195,15 @@ JS;
case
'email'
:
$tmp
=
$this
->
field
(
$this
->
model
,
$key
,
$optEl
)
->
input
(
$element
[
'type'
],
$opt
);
if
(
!
empty
(
$element
[
'hint'
]))
$tmp
=
$tmp
->
hint
(
$element
[
'hint'
]);
if
(
$element
[
'options'
][
'label'
]
===
false
)
$tmp
=
$tmp
->
label
(
false
);
$config
[
'options'
][]
=
$tmp
;
break
;
case
'password'
:
//$opt['value'] = '';
$optEl
[
'template'
]
=
'{label}{input}<div id="'
.
$element
[
'pwd-id'
]
.
'" class="is0 m-t-5"></div>{error}'
;
$config
[
'options'
][]
=
$this
->
field
(
$this
->
model
,
$key
,
$optEl
)
->
input
(
$element
[
'type'
],
$opt
);
$tmp
=
$this
->
field
(
$this
->
model
,
$key
,
$optEl
)
->
input
(
$element
[
'type'
],
$opt
);
if
(
$element
[
'options'
][
'label'
]
===
false
)
$tmp
=
$tmp
->
label
(
false
);
$config
[
'options'
][]
=
$tmp
;
break
;
case
'hidden'
:
$config
[
'options'
][]
=
$this
->
field
(
$this
->
model
,
$key
,
$optEl
)
->
hiddenInput
(
$opt
)
->
label
(
false
);
...
...
@@ -209,6 +216,7 @@ JS;
//$optEl['template'] = '{label}<div class="col-md-8">{input}</div>{error}{hint}';
$tmp
=
$this
->
field
(
$this
->
model
,
$key
,
$optEl
)
->
dropDownList
(
$element
[
'items'
],
$opt
);
if
(
!
empty
(
$element
[
'hint'
]))
$tmp
=
$tmp
->
hint
(
$element
[
'hint'
]);
if
(
$element
[
'options'
][
'label'
]
===
false
)
$tmp
=
$tmp
->
label
(
false
);
$config
[
'options'
][]
=
$tmp
;
break
;
case
'listBox'
:
...
...
@@ -272,7 +280,8 @@ JS;
if
(
$button
[
'type'
]
==
'htmlBlock'
)
$config
[
'options'
][]
=
$button
[
'value'
];
else
if
(
$button
[
'type'
]
==
'submit'
)
$config
[
'options'
][]
=
\yii\helpers\Html
::
submitButton
(
$button
[
'value'
],
[
'class'
=>
'btn btn-success'
]);
$config
[
'options'
][]
=
(
!
empty
(
$button
[
'class'
]))
?
\yii\helpers\Html
::
submitButton
(
$button
[
'value'
],
[
'class'
=>
$button
[
'class'
]])
:
\yii\helpers\Html
::
submitButton
(
$button
[
'value'
],
[
'class'
=>
'btn btn-success'
]);
else
if
(
$button
[
'type'
]
==
'cancel'
)
$config
[
'options'
][]
=
\yii\helpers\Html
::
resetButton
(
$button
[
'value'
],
[
'class'
=>
'btn btn-default'
]);
else
if
(
$button
[
'type'
]
==
'danger'
)
...
...
common/components/_BaseForm.php
View file @
69d8d25c
...
...
@@ -121,7 +121,7 @@ JS;
if
(
!
empty
(
$element
[
'options'
][
'label'
]))
$optEl
[
'labelOptions'
]
=
[
'label'
=>
$element
[
'options'
][
'label'
]];
if
(
!
empty
(
$element
[
'empty'
]))
$opt
[
'value'
]
=
$element
[
'empty'
];
$opt
[
'value'
]
=
$element
[
'empty'
];
switch
(
$element
[
'type'
])
{
case
'checkbox'
:
$opt
[
'data-render'
]
=
'switchery'
;
...
...
@@ -186,6 +186,7 @@ JS;
$config
[
'options'
][]
=
'<div style="clear: both;"></div>'
;
/* **************** */
}
unset
(
$config
[
'elements'
]);
if
(
$meta
)
{
//die(print_r($model->metaTag));
...
...
common/modules/rbac/models/AuthItem.php
View file @
69d8d25c
...
...
@@ -79,7 +79,7 @@ class AuthItem extends \common\components\ActiveRecordModel
}
public
function
getAssignment
()
{
return
$this
->
has
One
(
AuthAssignment
::
className
(),
[
'name'
=>
'item_
name'
]);
return
$this
->
has
Many
(
AuthAssignment
::
className
(),
[
'item_name'
=>
'
name'
]);
}
public
function
relations
()
...
...
@@ -97,7 +97,6 @@ class AuthItem extends \common\components\ActiveRecordModel
'auth_items_childs(parent, child)'
,
'condition'
=>
'type = "'
.
self
::
TYPE_TASK
.
'"'
),
'assignments'
=>
array
(
self
::
HAS_MANY
,
'AuthAssignment'
,
'itemname'
),
'users'
=>
array
(
self
::
HAS_MANY
,
'User'
,
'userid'
,
'through'
=>
'assignments'
)
);
}
...
...
@@ -188,7 +187,8 @@ class AuthItem extends \common\components\ActiveRecordModel
if
(
!
$roles
)
{
$roles
=
$this
->
findAllByAttributes
(
array
(
'type'
=>
self
::
TYPE_ROLE
//'type' => self::TYPE_ROLE
'rule_name'
=>
'group'
));
}
return
$roles
;
...
...
common/modules/school/controllers/CourseController.php
View file @
69d8d25c
...
...
@@ -6,6 +6,7 @@ use common\components\BaseController;
use
common\modules\school\models\Courses
;
use
common\modules\school\models\SearchCourses
;
use
common\modules\school\models\SearchLessons
;
use
common\modules\users\models\User
;
class
CourseController
extends
BaseController
{
...
...
@@ -23,7 +24,9 @@ class CourseController extends BaseController
$search
=
\Yii
::
$app
->
request
->
queryParams
;
$dataProvider
=
$searchModel
->
search
(
$search
);
return
$this
->
render
(
'index'
,
[
'dataProvider'
=>
$dataProvider
]);
$modelUser
=
new
User
();
$form
=
new
\common\components\BaseForm
(
'/common/modules/users/forms/RegistrationUserForm'
,
$modelUser
);
return
$this
->
render
(
'index'
,
[
'dataProvider'
=>
$dataProvider
,
'form'
=>
$form
->
out
]);
}
public
function
actionView
(
$id
)
...
...
common/modules/school/models/Courses.php
View file @
69d8d25c
...
...
@@ -26,7 +26,6 @@ class Courses extends \common\components\ActiveRecordModel
self
::
TYPE_DV
=>
'в разработке'
,
];
public
static
function
tableName
()
{
return
'courses'
;
...
...
common/modules/school/views/course/index.php
View file @
69d8d25c
...
...
@@ -49,12 +49,9 @@
<div
class=
"container"
>
<div
class=
"row"
>
<div
class=
"col-md-4 col-xs-6 col-sm-12"
>
<form
class=
"sh_reg_form"
>
<input
type=
"text"
class=
"input_st field-input required alphanumeric"
placeholder=
"Ваше имя*"
>
<input
type=
"tel"
class=
"input_st field-input required alphanumeric"
placeholder=
"Телефон*"
>
<input
type=
"email"
class=
"input_st field-input required email"
placeholder=
"E-mail*"
>
<button
class=
"save-button sh_bt_send"
>
Записаться
</button>
</form>
<?php
echo
$form
;
?>
<div
class=
"usl"
>
Проходя регистрацию вы подтверждаете
<br><a
href=
"#"
>
согласие на обработку персональных данных.
</a></div>
</div>
<div
class=
"col-md-8 col-xs-6 col-sm-12"
>
...
...
common/modules/users/controllers/UserController.php
View file @
69d8d25c
...
...
@@ -46,7 +46,7 @@ class UserController extends \common\components\BaseController {
}
public
function
loadModel
(
$id
)
{
public
function
loadModel
(
$id
,
$scopes
=
array
(),
$attribute
=
NULL
)
{
$model
=
User
::
model
()
->
findByPk
((
int
)
$id
);
if
(
$model
===
null
)
{
$this
->
pageNotFound
();
...
...
@@ -104,14 +104,15 @@ class UserController extends \common\components\BaseController {
public
function
actionRegistration
()
{
$model
=
new
User
;
die
(
''
);
$model
=
new
User
();
$model
->
scenario
=
User
::
SCENARIO_REGISTRATION
;
$form
=
new
BaseForm
(
'users.RegistrationForm'
,
$model
);
/*
$form = new BaseForm('users.RegistrationForm', $model);
$this->performAjaxValidation($model);
unset($form->elements['captcha']);
$is_created
=
false
;
$is_created = false;
*/
if
(
isset
(
$_POST
[
'User'
]))
{
$model
->
attributes
=
$_POST
[
'User'
];
...
...
common/modules/users/forms/RegistrationUserForm.php
0 → 100644
View file @
69d8d25c
<?php
use
yii\helpers\Url
;
use
common\modules\users\models\User
;
$elements
=
[
'name'
=>
[
'type'
=>
'text'
,
'placeholder'
=>
"Ваше имя*"
,
'options'
=>
[
'label'
=>
false
],
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]],
'email'
=>
[
'type'
=>
'text'
,
'placeholder'
=>
"E-mail*"
,
'options'
=>
[
'label'
=>
false
],
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]],
'password'
=>
[
'type'
=>
'password'
,
'placeholder'
=>
"Придумайте пароль*"
,
'options'
=>
[
'label'
=>
false
],
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]],
'password_c'
=>
[
'type'
=>
'password'
,
'placeholder'
=>
"Повторите пароль*"
,
'options'
=>
[
'label'
=>
false
],
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]],
'phone'
=>
[
'type'
=>
'text'
,
'placeholder'
=>
"Телефон"
,
'options'
=>
[
'label'
=>
false
],
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]],
'teltext'
=>
'<div class="teltext-block">Для участие в проводимых конкурсах укажите Ваш реальный номер телефона,
что бы мы смогли вас оповестить о результатах</div>'
,
'occupation'
=>
[
'type'
=>
'dropdownlist'
,
'items'
=>
User
::
$occupation_list
,
'placeholder'
=>
"Род занятий"
,
'options'
=>
[
'label'
=>
false
],
'empty'
=>
'Чем вы занимаетесь'
,
'inputOptions'
=>
[
'class'
=>
'input_st field-input required alphanumeric'
]
],
];
return
[
'activeForm'
=>
[
'id'
=>
'sh_reg_form'
,
'options'
=>
[
//'onsubmit'=>"ajaxSubmit(url: ".Url::toRoute(['/users/user/registration']).")";
'enctype'
=>
'multipart/form-data'
],
],
'elements'
=>
$elements
,
'buttons'
=>
[
'submit'
=>
[
'type'
=>
'submit'
,
'value'
=>
'Записаться'
,
'class'
=>
"save-button sh_bt_send"
]
]
];
common/modules/users/models/User.php
View file @
69d8d25c
...
...
@@ -16,7 +16,12 @@ use \common\modules\rbac\models\AuthAssignment;
class
User
extends
\common\components\ActiveRecordModel
implements
IdentityInterface
{
const
PAGE_SIZE
=
10
;
const
OCCUPATION_CHIEF_IT
=
1
;
const
OCCUPATION_MANAGER_IT
=
2
;
const
OCCUPATION_CREATOR
=
3
;
const
OCCUPATION_NOT_IT
=
4
;
const
STATUS_ACTIVE
=
'active'
;
const
STATUS_NEW
=
'new'
;
const
STATUS_BLOCKED
=
'blocked'
;
...
...
@@ -63,6 +68,14 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public
$tmp
;
//for external using. no delete!
// public $post;
public
static
$occupation_list
=
[
self
::
OCCUPATION_CHIEF_IT
=>
'Руководитель в IT сфере'
,
self
::
OCCUPATION_MANAGER_IT
=>
'Менеджер в IT сфере'
,
self
::
OCCUPATION_CREATOR
=>
'Разработчик'
,
self
::
OCCUPATION_NOT_IT
=>
'Не работаю в IT'
,
];
public
function
behaviors
()
{
return
[
...
...
@@ -91,7 +104,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
"send_email"
=>
"Отправить уведомление на почту"
,
"generate_new"
=>
"Сгенерировать пароль автоматически"
,
"post"
=>
"Должность"
,
"status"
=>
"Активен / заблокирован"
"status"
=>
"Активен / заблокирован"
,
"occupation"
=>
"Род занятий"
,
));
return
$attrs
;
...
...
@@ -136,7 +150,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self
::
SCENARIO_CHANGE_PASSWORD
,
self
::
SCENARIO_CREATE
,
],
'message'
=>
'Пожалуйста, укажите пароль'
],
[[
'password'
],
'string'
,
'min'
=>
4
,
'on'
=>
[
[[
'password'
],
'string'
,
'min'
=>
7
,
'on'
=>
[
self
::
SCENARIO_REGISTRATION
,
self
::
SCENARIO_CHANGE_PASSWORD
,
self
::
SCENARIO_UPDATE
,
...
...
@@ -183,6 +197,7 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
self
::
SCENARIO_SEARCH
,
self
::
SCENARIO_CREATE
,
]],
[[
'occupation'
],
'integer'
,
'max'
=>
11
],
[[
'tmp'
,
'role'
,
'sort'
,
'fio'
,
'name'
,
'surname'
,
'email'
,
'mobile_phone'
],
'safe'
],
];
}
...
...
@@ -355,8 +370,8 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public
function
relations
()
{
return
array
(
'assignment'
=>
array
(
self
::
HAS_ONE
,
'AuthAssignment'
,
'userid'
),
'city'
=>
array
(
self
::
BELONGS_TO
,
'City'
,
'city_id'
)
'assignment'
=>
array
(
self
::
HAS_ONE
,
'AuthAssignment'
,
'user
_
id'
),
'city'
=>
array
(
self
::
BELONGS_TO
,
'City'
,
'city_id'
)
);
}
...
...
@@ -394,18 +409,23 @@ class User extends \common\components\ActiveRecordModel implements IdentityInter
public
function
getRole
()
{
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
$auth
=
AuthItem
::
find
()
->
joinWith
(
'assignment'
,
true
)
->
andWhere
([
'rule_name'
=>
'group'
])
->
andWhere
([
'auth_assignment.user_id'
=>
$this
->
id
])
->
one
();
if (!$assigment)
return
$auth
->
name
;
/*$assigment = AuthAssignment::find(['userid' => $this->id])->one();
if (!$assigment)
{
$assigment
= new AuthAssignment();
$assigment = new AuthAssignment();
$assigment->item_name = AuthItem::ROLE_DEFAULT;
$assigment->user_id = $this->id;
$assigment->save(false);
}
return $assigment->role;
*/
return
'admin'
;
return $assigment->role;
return 'admin';
*/
}
public
function
getRoleName
()
...
...
console/migrations/m160204_213447_add_field_to_users_table.php
0 → 100644
View file @
69d8d25c
<?php
use
yii\db\Schema
;
use
yii\db\Migration
;
class
m160204_213447_add_field_to_users_table
extends
Migration
{
public
function
safeUp
()
{
$this
->
addColumn
(
'users'
,
'occupation'
,
Schema
::
TYPE_INTEGER
.
'(11)'
);
}
public
function
safeDown
()
{
$this
->
dropColumn
(
'users'
,
'occupation'
);
}
}
frontend/config/main.php
View file @
69d8d25c
...
...
@@ -22,6 +22,7 @@ return [
'school'
=>
[
'class'
=>
'common\modules\school\Module'
,],
'bids'
=>
[
'class'
=>
'common\modules\bids\Module'
],
'testings'
=>
[
'class'
=>
'common\modules\testings\Module'
,],
'users'
=>
[
'class'
=>
'common\modules\users\users'
,],
'sitemap'
=>
[
'class'
=>
'himiklab\sitemap\Sitemap'
,
'models'
=>
[
...
...
@@ -81,7 +82,7 @@ return [
//'css_linebreak_pos' => false,
],
'user'
=>
[
'identityClass'
=>
'common\modules\
scoring\models\ScClient
'
,
'identityClass'
=>
'common\modules\
users\models\User
'
,
'loginUrl'
=>
[
'/site/login'
],
'enableAutoLogin'
=>
true
,
],
...
...
@@ -165,6 +166,7 @@ return [
'school'
=>
'school/course/index'
,
'school/course/<id>'
=>
'school/course/view'
,
'school/lesson/<id>'
=>
'school/lesson/view'
,
'login'
=>
'site/login'
,
'<page:(/)>'
=>
'content/page/view'
,
'<_m>/<_c>/<_a>/<id:\d+>'
=>
'<_m>/<_c>/<_a>'
,
...
...
@@ -178,10 +180,10 @@ return [
],
'authManager'
=>
[
'class'
=>
'yii\rbac\DbManager'
,
/*
'connectionID' => 'db',
'connectionID'
=>
'db'
,
'itemTable'
=>
'auth_items'
,
'assignmentTable'
=>
'auth_assignments'
,
'itemChildTable' => 'auth_item_child',
*/
'itemChildTable'
=>
'auth_item_child'
,
'defaultRoles'
=>
[
'user'
,
'moderator'
,
...
...
frontend/controllers/SiteController.php
View file @
69d8d25c
...
...
@@ -3,7 +3,7 @@ namespace frontend\controllers;
use
common\modules\scoring\models\ScRequest
;
use
Yii
;
use
frontend\models\LoginForm
;
//
use frontend\models\LoginForm;
use
frontend\models\PasswordResetRequestForm
;
use
frontend\models\ResetPasswordForm
;
use
frontend\models\SignupForm
;
...
...
@@ -22,6 +22,7 @@ use common\modules\request\models\ScZodiac;
use
\yii\web\Response
;
use
\yii\widgets\ActiveForm
;
use
common\modules\scoring\models\ScClient
;
use
common\models\LoginForm
;
/**
* Site controller
...
...
@@ -115,6 +116,14 @@ class SiteController extends BaseController
}
public
function
actionLogin
()
{
//Yii::$app->user->getIdentity()->getRole()
$model
=
new
LoginForm
();
$model
->
load
(
Yii
::
$app
->
request
->
post
());
$model
->
login
();
}
/*public function actionLogin()
{
$this->layout = '//main-short';
$model = new \frontend\models\LoginForm();
...
...
@@ -178,7 +187,7 @@ class SiteController extends BaseController
'model' => $model,
]);
}
}
}
*/
public
function
actionLogout
()
{
...
...
frontend/views/layouts/foot.php
View file @
69d8d25c
...
...
@@ -22,5 +22,6 @@
<?php
$this
->
registerJsFile
(
'/js/jquery.inputmask.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
<?php
$this
->
registerJsFile
(
'/js/inputmask.phone.extensions.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
<?php
$this
->
registerJsFile
(
'/js/common.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
<?php
$this
->
registerJsFile
(
'/js/bids-form.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
\ No newline at end of file
<?php
$this
->
registerJsFile
(
'/js/common.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
<?php
$this
->
registerJsFile
(
'/js/jquery.form.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
<?php
$this
->
registerJsFile
(
'/js/bids-form.js'
,
[
'position'
=>
yii\web\View
::
POS_END
]);
?>
\ No newline at end of file
frontend/web/css/screen.css
View file @
69d8d25c
...
...
@@ -11458,4 +11458,10 @@ h6 {
}
.row
li
{
list-style
:
none
;
}
.teltext-block
{
margin-top
:
-40px
;
margin-bottom
:
15px
;
color
:
#698387
;
font-size
:
14px
;
}
\ No newline at end of file
frontend/web/js/common.js
View file @
69d8d25c
...
...
@@ -580,4 +580,67 @@ jQuery(document).ready(function(){
$
(
this
).
parent
().
toggleClass
(
"
box_off_hide
"
);
});
});
\ No newline at end of file
});
// prepare the form when the DOM is ready
$
(
document
).
ready
(
function
()
{
var
options
=
{
//target: '#output2', // target element(s) to be updated with server response
beforeSubmit
:
showRequest
,
// pre-submit callback
success
:
showResponse
,
// post-submit callback
// other available options:
url
:
'
/users/user/registration
'
// override for form's 'action' attribute
//type: type // 'get' or 'post', override for form's 'method' attribute
//dataType: null // 'xml', 'script', or 'json' (expected server response type)
//clearForm: true // clear all form fields after successful submit
//resetForm: true // reset the form after successful submit
// $.ajax options can be used here too, for example:
//timeout: 3000
};
// bind to the form's submit event
$
(
'
#sh_reg_form
'
).
submit
(
function
()
{
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
$
(
this
).
ajaxSubmit
(
options
);
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return
false
;
});
});
// pre-submit callback
function
showRequest
(
formData
,
jqForm
,
options
)
{
// formData is an array; here we use $.param to convert it to a string to display it
// but the form plugin does this for you automatically when it submits the data
var
queryString
=
$
.
param
(
formData
);
// jqForm is a jQuery object encapsulating the form element. To access the
// DOM element for the form do this:
// var formElement = jqForm[0];
//alert('About to submit: \n\n' + queryString);
// here we could return false to prevent the form from being submitted;
// returning anything other than false will allow the form submit to continue
return
true
;
}
// post-submit callback
function
showResponse
(
responseText
,
statusText
,
xhr
,
$form
)
{
// for normal html responses, the first argument to the success callback
// is the XMLHttpRequest object's responseText property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'xml' then the first argument to the success callback
// is the XMLHttpRequest object's responseXML property
// if the ajaxSubmit method was passed an Options Object with the dataType
// property set to 'json' then the first argument to the success callback
// is the json data object returned by the server
//alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
// '\n\nThe output div should have already been updated with the responseText.');
}
\ No newline at end of file
frontend/web/js/jquery.form.js
0 → 100644
View file @
69d8d25c
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment