Skip to content

Commit 58d5ab8

Browse files
committed
fix responsejs
1 parent 96ac0e8 commit 58d5ab8

File tree

8 files changed

+14
-978
lines changed

8 files changed

+14
-978
lines changed

assets/form-builder/js/forms/controller.js

+1
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@ var quill = new Quill('#textdescription', {
112112
field.setDataFieldFrom("data-source") // class
113113
field.render();
114114
});
115+
115116
/**
116117
* Add field to form
117118
* @param {event} e - event data object

assets/form-builder/js/forms/field.js

-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ factory.prototype = {
4747
if (input.value == '') {
4848
input.value = this.data[prop];
4949
}
50-
console.log(input);
5150
}
5251
},
5352

assets/form-builder/js/forms/form.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -259,12 +259,16 @@ MyFORM = (function() {
259259
* @returm {Boolean}
260260
*/
261261
add: function(o) {
262+
console.log(o);
263+
262264
try {
263265
if (o.hasOwnProperty('field')) {
264266
var field = this.filter(o);
267+
console.log(field);
265268

266269
this.model.body.push([field]);
267270
this.fields_with_data.push(field.name);
271+
console.log(o);
268272
this.post(o);
269273
this.render();
270274

@@ -274,7 +278,7 @@ MyFORM = (function() {
274278
}
275279
} catch (err) {
276280
console.log(err);
277-
alert('Error add field to form: uncorrect data')
281+
alert('Error add field to form: uncorrect data')
278282
}
279283
},
280284

@@ -368,7 +372,7 @@ MyFORM = (function() {
368372
*/
369373
executeModules: function() {
370374
for (var prop in this.modules) {
371-
this.modules[prop]();
375+
this.modules[prop](this);
372376
}
373377
},
374378

assets/form-builder/js/forms/form.module.response.js

+4-14
Original file line numberDiff line numberDiff line change
@@ -7,27 +7,17 @@
77
*/
88

99
var MyFORM = MyFORM || {};
10-
MyFORM.response = function (form, field){
10+
MyFORM.response = function (){
1111

1212
var html = '<div class="row form-group-sm"> ' +
1313
'<label class="col-sm-3 control-label">Text respond</label> ' +
1414
'<div class="col-sm-9"> ' +
1515
'<textarea id="response" class="form-control input-sm" rows="5" disabled>Respond work if in form is field with name email</textarea> ' +
16-
'</div> ' +
17-
'</div>';
18-
field = field || 'email';
16+
'</div></div>';
1917

2018
$("#widget-form-options").append(html);
2119

22-
return function(){
23-
fields_with_data = h.getAllProperty('name', form.body);
24-
25-
for (var i = 0; i < fields_with_data.length; i++) {
26-
27-
if (fields_with_data[i] === field){
28-
$('#response').prop('disabled', false); break;
29-
}
30-
$('#response').prop('disabled', true);
31-
}
20+
return function(form){
21+
$('#response').prop('disabled', form.fields_with_data.indexOf('email') < 0);
3222
}
3323
}

controllers/ModuleController.php

+1-3
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,12 @@ public function actionView(string $url) {
9494
$form->updateCounters(['answer' => 1 ]);
9595
Yii::$app->session->setFlash('success', Yii::t('builder', 'Form completed'));
9696

97-
if ($this->module->sendEmail && is_string($this->module->emailSender) && isset($data['email']) && isset($form['response']) ) {
9897
SendEmail::widget([
9998
'from' => $this->module->emailSender,
10099
'to' => $data['email'],
101100
'subject' => 'subject',
102-
'textBody' => $form['response'],
101+
'textBody' => 'test',
103102
]);
104-
}
105103

106104

107105
} else {

tags

-956
This file was deleted.

tests/php/unit/FormUpdateTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ public function testInit() {
3030
$this->assertEquals( $this->formBuilder->db, 'db');
3131
$this->assertFalse( $this->formBuilder->test_mode);
3232
$this->assertTrue( $this->formBuilder->easy_mode);
33-
$this->assertFalse( $this->formBuilder->email_response);
33+
$this->assertFalse( $this->formBuilder->send_email);
3434
}
3535

3636
public function testTableSchema() {

views/builder/main.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@
7373
if ($send_email){
7474
// add module Email send after submit form (work if in forms is field with attribute name 'email')
7575
// form.modules are initalized each time the form is rendered
76-
$this->registerJs("form.modules.response = MyFORM.response(form)", 4);
76+
$this->registerJs("form.modules.response = MyFORM.response()", 4);
7777
}
7878
$this->registerJs("
7979
form.init(".Json::encode($jsConfig).");

0 commit comments

Comments
 (0)