我正在尝试使用
在新操作中的会话中为对象分配一个对象using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Windows;
using System.Windows.Data;
namespace WpfApplication2
{
public class ThingConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return new List<string>(((NamedThing)value).Name.Split(' '));
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return ((List<string>)value).Aggregate((s, ss) => s + " " + ss);
}
}
public class NamedThing
{
public string Name { get; set; }
}
public class MYViewModel
{
public ObservableCollection<NamedThing> ThingsList { get; set; }
public MYViewModel()
{
ThingsList = new ObservableCollection<NamedThing>
{
new NamedThing {Name = "Short"},
new NamedThing {Name = "VeryVeryLongWord"},
new NamedThing {Name = "Several Words in a Row"}
};
}
}
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
}
}
$project = $this->userInput->getProject();
$this->view->assign('project', $project);
显示标记为prototype,proxy和persistable的完整对象。所以我认为这有效......
但是表格没有填写项目中的内容。
<f:debug>{project}<f:debug>
这很奇怪,因为在编辑操作中我做的是同样的,它在那里工作..
<f:form controller="mycontroller" action="create" class="form-horizontal" objectName="project" method="POST" enctype="multipart/form-data" additionalAttributes="{role:'form', novalidate:'true'}">
唯一的区别是,对象来自数据库中的存储库。
有什么想法吗?
答案 0 :(得分:0)
好吧,我回答我自己的问题......我必须将对象属性object="{project}"
放到这样的表单中:
<f:form action="update" objectName="project" object="{project}" class="form-horizontal" enctype="multipart/form-data" additionalAttributes="{role:'form', novalidate:'true'}">