Ver código fonte

Resolve formbuilder checkboxes

Cerothen 9 anos atrás
pai
commit
965c3a1849
2 arquivos alterados com 34 adições e 37 exclusões
  1. 6 3
      functions.php
  2. 28 34
      settings.php

+ 6 - 3
functions.php

@@ -1138,12 +1138,16 @@ function buildSettings($array) {
 	<script>
 		$(document).ready(function() {
 			$(\'#'.$pageID.'_form\').find(\'input, select, textarea\').on(\'change\', function() {
-				$(this).attr(\'data-changed\', \'true\');
+				$(this).attr(\'data-changed\', \'true\');			
 			});
 			$(\'#'.$pageID.'_form\').submit(function () {
 				var newVals = {};
 				$(\'#'.$pageID.'_form\').find(\'[data-changed=true]\').each(function() {
-					newVals[$(this).attr(\'name\')] = $(this).val();
+					if (this.type == \'checkbox\') {
+						newVals[this.name] = this.checked;
+					} else {
+						newVals[this.name] = ele.val();
+					}
 				});
 				$.post(\'ajax.php?a=update-config\', newVals, function(data) {
 					console.log(data);
@@ -1206,7 +1210,6 @@ function buildField($params) {
 		case 'toggle':
 			$checked = ((is_bool($val) && $val) || trim($val) === 'true'?' checked':'');
 			return '
-			<input id="'.$id.'_disabled" name="'.$name.'" type="hidden" class="switcher switcher-success" value="false">
 			<input id="'.$id.'" name="'.$name.'" type="checkbox" class="switcher switcher-success'.$class.'" '.implode(' ',$tags).' value="'.$val.'"'.$checked.'><label for="'.$id.'"></label>'.$label.'
 			';
 		case 'date':

+ 28 - 34
settings.php

@@ -1622,40 +1622,6 @@ echo buildSettings(
 		'title' => 'Advanced Settings',
 		'id' => 'advanced_settings',
 		'onready' => '$(\'.be-auth\').each(function() { $(this).parent().hide(); }); $(\'.be-auth-\'+$(\'#authBackend_id\').val()).each(function() { $(this).parent().show(); });',
-		'fields' => array(
-			array(
-				'type' => 'header',
-				'value' => "General",
-			),
-			array(
-				'type' => 'text',
-				'labelTranslate' => 'REGISTER_PASSWORD',
-				'name' => 'registerPassword',
-				//'pattern' => '[a-zA-Z0-9]{32}',
-				'value' => REGISTERPASSWORD,
-			),
-			array(
-				'type' => 'text',
-				'labelTranslate' => 'COOKIE_DOMAIN',
-				'name' => 'domain',
-				//'pattern' => '[a-zA-Z0-9]{32}',
-				'value' => DOMAIN,
-			),
-			array(
-				'type' => 'password',
-				'labelTranslate' => 'COOKIE_PASSWORD',
-				'name' => 'cookiePassword',
-				//'pattern' => '[a-zA-Z0-9]{32}',
-				'value' => (empty(COOKIEPASSWORD)?'':randString(20)),
-			),
-			array(
-				'type' => 'checkbox',
-				'labelTranslate' => 'MULTIPLE_LOGINS',
-				'name' => 'multipleLogin',
-				//'pattern' => '[a-zA-Z0-9]{32}',
-				'value' => MULTIPLELOGIN,
-			),
-		),
 		'tabs' => array(
 			array(
 				'title' => 'Backend Authentication',
@@ -1764,6 +1730,34 @@ echo buildSettings(
 						'value' => TIMEZONE,
 						'options' => timezoneOptions(),
 					),
+					array(
+						'type' => 'text',
+						'labelTranslate' => 'REGISTER_PASSWORD',
+						'name' => 'registerPassword',
+						//'pattern' => '[a-zA-Z0-9]{32}',
+						'value' => REGISTERPASSWORD,
+					),
+					array(
+						'type' => 'text',
+						'labelTranslate' => 'COOKIE_DOMAIN',
+						'name' => 'domain',
+						//'pattern' => '[a-zA-Z0-9]{32}',
+						'value' => DOMAIN,
+					),
+					array(
+						'type' => 'password',
+						'labelTranslate' => 'COOKIE_PASSWORD',
+						'name' => 'cookiePassword',
+						//'pattern' => '[a-zA-Z0-9]{32}',
+						'value' => (empty(COOKIEPASSWORD)?'':randString(20)),
+					),
+					array(
+						'type' => 'checkbox',
+						'labelTranslate' => 'MULTIPLE_LOGINS',
+						'name' => 'multipleLogin',
+						//'pattern' => '[a-zA-Z0-9]{32}',
+						'value' => MULTIPLELOGIN,
+					),
 				),
 			),
 			array(