I'm sure this has been answered before but I think my search vocabulary is throwing me off. I need to be able to add data to the elements of the form below, specifically the "Commands", "Parameters", and "Security" fields, before I submit the whole form.
@using (Html.BeginForm("CreateTemplateStep", "TemplateStep"))
{
<div>
@Html.LabelFor(model => model.Name)
@Html.EditorFor(model => model.Name)
</div>
<div>
@Html.LabelFor(model => model.ExecutionOrder)
@Html.EditorFor(model => model.ExecutionOrder)
</div>
<div>
@Html.LabelFor(model => model.Description)
@Html.EditorFor(model => model.Description)
</div>
<div>
@Html.LabelFor(model => model.Type)
@Html.DropDownListFor(model => model.Type, Enum.GetNames(typeof(Helion.JobScheduler.Models.StepType)).Select(e => new SelectListItem { Text = e }))
</div>
<div>
@Html.LabelFor(model => model.Commands)
@Html.EditorFor(model => model.Commands)
</div>
<div>
@Html.LabelFor(model => model.Parameters)
@Html.EditorFor(model => model.Parameters)
</div>
<div>
@Html.LabelFor(model => model.Security)
@Html.EditorFor(model => model.Security)
</div>
<button type="submit" class="btn btn-default btn-primary">Save</button>
<input type="button" value="Cancel" onclick="location.href='@Url.Action("Template","Template")';" class="btn btn-default" />
}
So I will need to add as many commands as I need then when I hit submit on the form the whole list of commands will be submitted. Any help is greatly appreciated.
[DataModel("JOB", "TEMPLATE_STEP")]
public class TemplateStep
{
public const string TABLE_NAME = "TEMPLATE_STEP";
[PKIdentityDataColumn("TEMPLATE_STEP_ID")]
public long? TemplateStepID { get; set; }
[DataModelColumn("TEMPLATE_ID")]
public long TemplateID { get; set; }
[DataModelColumn("EXECUTION_ORDER")]
public int ExecutionOrder { get; set; }
[DataModelColumn("NAME")]
public string Name { get; set; }
[DataModelColumn("DESCRIPTION")]
public string Description { get; set; }
[DataModelColumn("TYPE")]
public StepType Type { get; set; }
[DataModelColumn("COMMAND_XML")]
public string CommandXML { get; set; }
[DataModelColumn("PARAMETER_XML")]
public string ParameterXML { get; set; }
[DataModelColumn("SECURITY_XML")]
public string SecurityXML { get; set; }
public List<NameValuePair> Commands { get; set; }
public List<NameValuePair> Parameters { get; set; }
public List<NameValuePair> Security { get; set; }
}
Here is the associated model as well as the NameValuePair class.
public class NameValuePair
{
public string Name { get; set; }
public string Value { get; set; }
}
We used a custom "KeyValuePair" because we couldn't get the editor templates to work for the actual "KeyValuePair" structure.