duanqian8867 2012-10-16 19:35
浏览 38
已采纳

具有“可选”必填字段的实体。 取决于UI中使用的表单

I have a Company entity in Doctrine and Symfony 2. In my Entity I have declared fields such as Name, Street, Zip, City, Country etc... as required using the Doctrine annotations.

Now, in the User Experience I would like people to be able to add a new Company in a quick way.

For example, when adding a project and the user needs to add new Company that's not yet in the database, I'd like for them to enter the Company Name only and automatically create a task in their dashboard, "COMPLETE COMPANY X".

In that way, they can focus on their primary task, which is adding a new project and fill in the required company fields later. But the good thing is that the Company now has an ID and record in the DB and I can use it to link to projects etc...

How would you tackle this problem? In my current setup the required fields are set in the Model and so the database fields are set to NOT NULL.

Should I create a class LightCompany with only required attribute Name and then a class ExtendedCompany which extends LightCompany with all the required fields?

Is there a better way?

  • 写回答

1条回答 默认 最新

  • dsc862009 2012-10-16 20:33
    关注

    You can set form validation groups based on submitted data. See here for more info.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题
  • ¥15 linux驱动,linux应用,多线程