mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-09-22 20:13:50 +08:00
Changed the default value for SetupViewModel to be the built-in database option and added a check to ensure a connection string was entered when the sql database option is checked
--HG-- branch : dev
This commit is contained in:
@@ -46,11 +46,15 @@ namespace Orchard.Setup.Controllers {
|
||||
|
||||
[HttpPost, ActionName("Index")]
|
||||
public ActionResult IndexPOST(SetupViewModel model) {
|
||||
try {
|
||||
//HACK: (erikpo) Couldn't get a custom ValidationAttribute to validate two properties
|
||||
if (!model.DatabaseOptions && string.IsNullOrEmpty(model.DatabaseConnectionString))
|
||||
ModelState.AddModelError("DatabaseConnectionString", "A SQL connection string is required");
|
||||
|
||||
if (!ModelState.IsValid) {
|
||||
return Index(model);
|
||||
}
|
||||
|
||||
try {
|
||||
var shellSettings = new ShellSettings {
|
||||
Name = "default",
|
||||
DataProvider = model.DatabaseOptions ? "SQLite" : "SqlServer",
|
||||
|
@@ -4,14 +4,18 @@ using Orchard.Mvc.ViewModels;
|
||||
|
||||
namespace Orchard.Setup.ViewModels {
|
||||
public class SetupViewModel : BaseViewModel {
|
||||
public SetupViewModel() {
|
||||
DatabaseOptions = true;
|
||||
}
|
||||
|
||||
[Required, StringLength(70)]
|
||||
public string SiteName { get; set; }
|
||||
[Required, StringLengthMin(3), StringLength(25)]
|
||||
public string AdminUsername { get; set; }
|
||||
[Required, StringLengthMin(6), StringLength(50)]
|
||||
public string AdminPassword { get; set; }
|
||||
public bool DatabaseOptions { get; set; }
|
||||
[SqlDatabaseConnectionString]
|
||||
public string DatabaseConnectionString { get; set; }
|
||||
public bool DatabaseOptions { get; set; }
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user