title: How can I send tinyMCE textarea editor content to inside controller using Symfony3 and Ajax
body: <p>I have two tinyMCE editor with id's like #homepage, #thankyoupage, I want to send tinymce textarea content to inside symfony controller.</p>
  
  <p>This is my front end part:</p>
  
  <p><a href="https://i.stack.imgur.com/TE1Ys.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TE1Ys.jpg" alt="enter image description here"></a></p>
  
  <p>I am trying to send normal textarea value using jQuery ajax like below but I am  getting undefined value.</p>
  
  <pre><code>$(document).ready(function () {
      var array_data = {};
      array_data['dedline'] = $('#homepage').val();
      array_data['homepage'] = $('#thankyoupage').val();
      array_data['thankyoupage'] = $('#deadlinetoanswer').val();
      $.ajax({
          type: 'POST',
          url: Routing.generate("invitation"),
          contentType: 'application/x-www-form-urlencoded',
          data: {
              data_array: array_data
          },
          success: function (result, status, xhr) {
              var res = JSON.parse(result);
              console.log(res);
          },
          error: function (xhr, status, error) {
              console.log('error1');
          }
      });
  });
  </code></pre>
  
  <p><strong>This is my form:</strong></p>
  
  <pre><code>$builder-&gt;add('deadlinetoanswer', ChoiceType::class, array(
      'choices' =&gt; array(
          '2 days' =&gt; 2,
          '3 days' =&gt; 3,
          '5 days' =&gt; 5,
          '7 days' =&gt; 7,
          '10 days' =&gt; 10,
          '15 days' =&gt; 15,
          'Until' =&gt; 'until'
      )
  ));
  
  $builder-&gt;add('prerecwelcomemsg', TextareaType::class, array(
      'required' =&gt; true,
      'attr' =&gt; array('class' =&gt; 'tinymce', 'id' =&gt; 'homepage', 'data-theme' =&gt; 'bbcode', 'style' =&gt; 'height: 380px', 'placeholder' =&gt; "Welcome...")
  ));
  
  $builder-&gt;add('prerecthankyoumsg', TextareaType::class, array(
      'required' =&gt; true,
      'attr' =&gt; array('class' =&gt; 'tinymce', 'id' =&gt; 'thankyoupage', 'data-theme' =&gt; 'bbcode', 'style' =&gt; 'height: 380px', 'placeholder' =&gt; "Thank you...")
  ));
  </code></pre>
  
  <p><strong>This is my controller:</strong></p>
  
  <pre><code>/**
   * @Route("/prerecorded/invitation", name="invitation", options={"expose"=true})
   */
  public
  function invitationAction(Request $request) {
      $em = $this - &gt; getDoctrine() - &gt; getManager();
      $form = $this - &gt; createForm(InvitationType::class);
      $form - &gt; handleRequest($request);
  
      if ($request - &gt; isXmlHttpRequest()) {
          $res_arr = $request - &gt; request - &gt; get('data_array');
          //   $this-&gt;container-&gt;get('logger')-&gt;addInfo('somesh'.$res_arr);           
          if ($res_arr) {
              $campaignid = 1;
              $campaign = $em - &gt; getRepository('TraceBundle:Campaign') - &gt; findOneBy(array('id' =&gt; $campaignid));
              $campaign - &gt; setDeadlinetoanswer('');
              $campaign - &gt; setPrerecwelcomemsg('hello');
              $campaign - &gt; setPrerecthankyoumsg('how r u');
              $em - &gt; persist($campaign);
              $em - &gt; flush();
              return new Response(json_encode($campaignid));
          }
      }
      return $this - &gt; render('TraceBundle:Campaign:invitation.html.twig', array(
          'form' =&gt; $form - &gt; createView(),
      ));
  }
  </code></pre>
  
  <p><strong>and my config.yml</strong></p>
  
  <pre><code>stfalcon_tinymce:
      include_jquery: true
      tinymce_jquery: true
      selector: ".tinymce"
    #  base_url: "http://yourdomain.com/" # this parameter may be included if you need to override the assets_base_urls for your template engine (to override a CDN base url)
      # Get current language from the parameters.ini
      language: %locale%
      # Custom buttons
      tinymce_buttons:
          stfalcon: # Id of the first button
              title: "Stfalcon"
              image: "http://stfalcon.com/favicon.ico"
  
      theme:
          # Simple theme: same as default theme
          simple: ~
  
          # Advanced theme with almost all enabled plugins
          advanced:
               plugins:
                   - "advlist autolink lists link image charmap print preview hr anchor pagebreak"
                   - "searchreplace wordcount visualblocks visualchars code fullscreen"
                   - "insertdatetime media nonbreaking save table contextmenu directionality"
                   - "emoticons template paste textcolor"
               toolbar1: "insertfile undo redo | styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist numlist outdent indent | link image"
               toolbar2: "print preview media | forecolor backcolor emoticons | stfalcon | example"
               image_advtab: true
               templates:
                   - {title: 'Test template 1', content: 'Test 1'}
                   - {title: 'Test template 2', content: 'Test 2'}
          # BBCode tag compatible theme (see http://www.bbcode.org/reference.php)
          bbcode:
               plugins: ["bbcode, code, link, preview"]
               menubar: false               
               toolbar1: "styleselect | bold italic | alignleft aligncenter alignright alignjustify | bullist "
  </code></pre>
  
  <p>This is first time I am working tinyMCE editor, really I am not sure where I am doing wrong. Please help me anyone and let me know is there any extra information is needed.</p>
  
  <p>Thanks in advance</p>