Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8340731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T05:15:36+00:00 2026-06-09T05:15:36+00:00

I have a class called Domains with properties – domain, user, start date, due

  • 0

I have a class called Domains with properties – domain, user, start date, due date… I use it once for creating the database with annotations, and once for creating a form in which take place only a few of the properties in the class Domains – for example start and due date (the form is used for update of the information). I create the form in this way:

public function buildForm(FormBuilder $builder, array $options)
{
    $builder->add('start_date', 'date', array('widget' => 'single_text', 'format' => 'yyyy-MM-dd')); ...

My question is: is it possible to put both kind of annotations – for validation and for the database like this:

/**
 * @ORM\Column(type="date", nullable=true)
 */
/**
 * @Assert\NotBlank()
 * @Assert\Type("\DateTime")
 */
protected $start_date;

If no will it be possible if the one is with annotations and the other with a .yml file? And if yes is it a good practice at all? I did it because a lot of the properties are the same – only the class which shlould be used with the database has more of them and it seems pointless to write two class part of which are identical. I thought about inheritance, too but the problem still stays. Please tell me what will fit the best! 🙂 Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T05:15:38+00:00Added an answer on June 9, 2026 at 5:15 am

    Yes, you can put both kinds of annotations. Do it like this:

    /**
     * @ORM\Column(type="date", nullable=true)
     * @Assert\NotBlank()
     * @Assert\Type("\DateTime")
     */
    protected $start_date;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Let's say I have a domain class called User which can follow other User
I've got a class called Domain. Each Domain can have multiple sub-domains (of the
I have a domain class called FoapRequest. I want one of the properties called
I'm working on a grails legacy project. A domain class called User exists. It
I am using MVC3 and Entity Framework. I have a class called User with
I have a Domain object called User and UserCreateViewModel.Automapper is used for mapping from
Let's say I have a multitenant app with a domain class called Store. Each
Let's say I have a domain class called ShopCategoryPageTab. And I have a domain
In our Core domain model design, we have got a class called Category whose
I have a domain class called Flight that represents a flight that has been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.