@@ -414,9 +414,6 @@ function elasticsearch_connector_cluster_indices_add($form, &$form_state, $clust
414
414
'#description ' => t ('Enter the number of shards replicas. ' )
415
415
);
416
416
417
- // TODO: Add other options if necessary at later stage.
418
-
419
-
420
417
$ form ['actions ' ] = array (
421
418
'#type ' => 'actions ' ,
422
419
);
@@ -442,7 +439,7 @@ function elasticsearch_connector_cluster_indices_add_validate($form, &$form_stat
442
439
form_set_error ('index_name ' , t ('Enter an index name that begins with a letter and contains only letters, numbers, and underscores. ' ));
443
440
}
444
441
445
- if (!is_numeric ($ values ['num_of_shards ' ])) {
442
+ if (!is_numeric ($ values ['num_of_shards ' ]) || $ values [ ' num_of_shards ' ] < 1 ) {
446
443
form_set_error ('num_of_shards ' , t ('Invalid number of shards. ' ));
447
444
}
448
445
@@ -458,7 +455,8 @@ function elasticsearch_connector_cluster_indices_add_validate($form, &$form_stat
458
455
*/
459
456
function elasticsearch_connector_cluster_indices_add_submit ($ form , &$ form_state ) {
460
457
$ values = $ form_state ['values ' ];
461
- $ client = elasticsearch_connector_load_library ($ form ['#cluster ' ]);
458
+ $ cluster = $ form ['#cluster ' ];
459
+ $ client = elasticsearch_connector_load_library ($ cluster );
462
460
if ($ client ) {
463
461
try {
464
462
$ index_params ['index ' ] = $ values ['index_name ' ];
@@ -471,6 +469,12 @@ function elasticsearch_connector_cluster_indices_add_submit($form, &$form_state)
471
469
else {
472
470
drupal_set_message (t ('Fail to create the index %index ' , array ('%index ' => $ values ['index_name ' ])), 'error ' );
473
471
}
472
+
473
+ // If the form has been opened in dialog, close the window if it was
474
+ // setup to do so.
475
+ if (elasticsearch_connector_in_dialog () && elasticsearch_connector_close_on_submit ()) {
476
+ elasticsearch_connector_close_on_redirect ($ cluster ->cluster_id , $ values ['index_name ' ]);
477
+ }
474
478
}
475
479
catch (Exception $ e ) {
476
480
drupal_set_message ($ e ->getMessage (), 'error ' );
0 commit comments