0

I am trying to understand how to create a basic form in symfony2. I am aware of all the perks for using DQL / Entities to manipulate database records.

However, I am not sure I understand why I would want to create an Entity for search functionality? Right now, my search functionality works well, but I don't understand what the justification is to using entities for a simple one input form? It seems like overkill

Thanks for the clarification

My search controller looks something like this:

 //namespace etc..

class Search
{
    protected $word;
    protected $page;

    public function getQ(){
        return $this->word;
    }
    public function setQ($word){
        return $this->word = $word;
    }
    public function getPage(){
        return $this->page;
    }
    public function setPage($page){
        return $this->page;
    }
}
1
  • arrays work just fine in forms. Commented Feb 8, 2014 at 20:53

1 Answer 1

1

You don't need to create Entity for simple forms like contact form, search form, etc. Forms are often being used to create or update data in the database, but they do not require them.

Here is an example of usage of the symfony2 form, which does everything without entity (including validation):

How to create a contact form using Symfony2

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.