I have two AR domain objects Project and Status.
[ActiveRecord]
public class Project ...
{
....
[BelongsTo("StatusId", Access =
PropertyAccess.FieldCamelcaseUnderscore)]
[ValidateNonEmpty("Status required.")]
public Status Status { get { return _status; } set { _status =
value; } }
...
}
[ActiveRecord]
public class Status
{
....
[Property(NotNull = true, Access =
PropertyAccess.FieldLowercaseUnderscore)]
[ValidateNonEmpty("Name required."), ValidateIsUnique("Status
with this name already exists (Statuses must be unique).")]
public string Name { get { return _name; } set { _name =
value; } }
[Property(NotNull = false, Access =
PropertyAccess.FieldLowercaseUnderscore)]
public String Description { get { return _description; } set
{ _description = value; } }
...
}
A portion of my project/new.brail view, I have
<tr>
<td class="label">
${FormHelper.LabelFor("project.status", "Status:", {})}
</td>
<td colspan="3">
<div id="status">${FormHelper.Select("project.status",
statuses, { @value: 'Id', @text: 'Name' })}</div>
</td>
</tr>
So in my controller, after I post to Create, I have
public class ProjectController : ARSmartDispatcherController
{
...
public void Create([ARDataBind("project")] Project project,
String q)
{
project.Status =
Status.Find(Int32.Parse(Params["project.status"]));
project.Create();
RedirectToAction("show", String.Format("id={0}",
project.Id));
}
...
}
Notice that I have to do a
Status.Find(Int32.Parse(Params["project.status"])). If I don't,
project.status is null and my project.Create() throws. I am under the
impression that I did not have to do that and ARDataBind,
ARSmartDispatcherController would instantiate project.status for me.
What am I misunderstanding or doing wrong?
To add to my confusion, I have two nested arrays that get populated
based off checklists, and those get populated just fine. Project.name
and project.description that are simple text fields also get
populated. Is this something specific with Select lists?
I am running nightly build 921.
I would appreciate any help.
Jason
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/castle-project-users?hl=en
-~----------~----~----~----~------~----~------~--~---