title: Add Record With API with use of form in symfony 2
body: <p>This is my basic action for add record through api</p>
  
  <pre><code>    public function createAction(Request $request){
        $data = array();
        $data['employeeCode'] = $request-&gt;request-&gt;get('employeeCode');
        $data['employeeDescription'] = $request-&gt;request-&gt;get('employeeDescription');
        $data['firstName'] = $request-&gt;request-&gt;get('firstName');
        $data['lastName'] = $request-&gt;request-&gt;get('lastName');
        $data['address'] = $request-&gt;request-&gt;get('address');
        $data['suburb'] = $request-&gt;request-&gt;get('suburb');
        $data['postcode'] = $request-&gt;request-&gt;get('postcode');
        $data['country'] = $request-&gt;request-&gt;get('country');
        $data['phone'] = $request-&gt;request-&gt;get('phone');
        $data['mobile'] = $request-&gt;request-&gt;get('mobile');
  
        $emp = new Employees();
        $emp-&gt;setEmployeeCode($data['employeeCode']);
        $emp-&gt;setEmployeeDescription($data['employeeDescription']);
        $emp-&gt;setFirstName($data['firstName'] );
        $emp-&gt;setLastName($data['lastName']);
        $emp-&gt;setAddress($data['address']);
        $emp-&gt;setSuburb($data['suburb']);
        $emp-&gt;setCountry($data['country']);
        $emp-&gt;setSuburb($data['phone']);
        $emp-&gt;setCountry($data['mobile']);
  
        $em = $this-&gt;get('doctrine')-&gt;getEntityManager();
        $em-&gt;persist($emp);
        $em-&gt;flush();
        $view = View::create();
        $view-&gt;setData($emp);
  
        return $view;
  </code></pre>
  
  <p>this works for me but i want to bind it with my employee form so i can get  every validation from my form validator and i am new to symfony2 so i dont know that how to do it...</p>