Bonjour,

je cherche a ajouter un note en ajax dans fullCalendar pour cela j'ai installer le plugin adesigns/calendar-bundle.

voici la partie js:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
$(function() {
    var date = new Date();
    var d = date.getDate();
    var m = date.getMonth();
    var y = date.getFullYear();
 
    $('#calendar-holder').fullCalendar({
        theme: false,
        header: {
            left: 'prev, next',
            center: 'title',
            right: 'month,basicWeek,basicDay,'
        },
        lazyFetching: true,
        timeFormat: {
            // for agendaWeek and agendaDay
            agenda: 'h:mmt', // 5:00 - 6:30
 
            // for all other views
            '': 'h:mmt'            // 7p
        },
        eventSources: [
            {
//                            url: "{{path('fullcalendar_loader')}}", 
                url: Routing.generate('fullcalendar_loader'),
                type: 'POST',
                error: function() {
                    //alert('There was an error while fetching Google Calendar!');
                }
            }
        ],
        selectable: true,
        selectHelper: true,
        select: function(start, end, allDay) {
            var title = prompt('Event Title:');
            if (title) {
                start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");
                end = $.fullCalendar.formatDate(end, "yyyy-MM-dd HH:mm:ss");
                $.ajax({
                    url: Routing.generate('BazarBasBundle_admin_bas_add_event'),
                    data: 'title=' + title + '&start=' + start + '&end=' + end,
                    type: "POST",
                    success: function(json) {
                        alert('OK');
                    }
                });
                calendar.fullCalendar('renderEvent',
                        {
                            title: title,
                            start: start,
                            end: end,
                            allDay: allDay
                        },
                true // make the event "stick"
                        );
            }
            calendar.fullCalendar('unselect');
        }
    });
 
});
entity:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
 
namespace Bazar\BasBundle\Entity;
use Symfony\Component\Validator\Constraints as Assert;
use Doctrine\ORM\Mapping as ORM;
 
/**
 * Calendriller
 *
 * @ORM\Table(name="kuma_calendriller")
 * @ORM\Entity(repositoryClass="Bazar\BasBundle\Entity\CalendrillerRepository")
 */
class Calendriller
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;
 
    /**
     * @var \DateTime
     *
     * @ORM\Column(name="start", type="datetime")
     */
    private $start;
 
    /**
     * @var \DateTime
     * 
     * @ORM\Column(name="end", type="datetime")
     */
    private $end;
 
    /**
     * @var string
     *
     * @ORM\Column(name="title", type="string", length=255)
     */
    private $title;
    /**
   * Sets an event's background color.
   *
   * @var string
   *
   * @ORM\Column(name="bgColor", type="string", length=255, nullable=true)
   */
       protected $bgColor;
 
    /**
     * Get id
     *
     * @return integer 
     */
    public function getId()
    {
        return $this->id;
    }
 
 
    /**
     * Set start
     *
     * @param \DateTime $start
     * @return Calendriller
     */
    public function setStart(\DateTime $start=null)
    {
        $this->start = $start;
 
        return $this;
    }
 
    /**
     * Get start
     *
     * @return \DateTime 
     */
    public function getStart()
    {
        return $this->start;
    }
 
    /**
     * Set end
     *
     * @param \DateTime $end
     * @return Calendriller
     */
    public function setEnd(\DateTime  $end=null)
    {
        $this->end = $end;
 
 
 
        return $this;
    }
 
    /**
     * Get end
     *
     * @return \DateTime 
     */
    public function getEnd()
    {
        return $this->end;
    }
 
    /**
     * Set title
     *
     * @param string $title
     * @return Calendriller
     */
    public function setTitle($title)
    {
        $this->title = $title;
 
        return $this;
    }
 
    /**
     * Get title
     *
     * @return string 
     */
    public function getTitle()
    {
        return $this->title;
    }
 
    /**
     * Set bgcolor
     *
     * @param string $bgcolor
     * @return Calendriller
     */
    public function setBgcolor($bgcolor)
    {
        $this->bgcolor = $bgcolor;
 
        return $this;
    }
 
    /**
     * Get bgcolor
     *
     * @return string 
     */
    public function getBgcolor()
    {
        return $this->bgColor;
    }
}
mon controller:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
    public function AddEventsAction(Request $request)
          {
                $em = $this->getDoctrine()->getManager();
                $request = $this->getRequest();
 
                $Calen = new Calendriller();
                $Calen->setTitle($request->get('title'));
                $Calen->setStart(new \DateTime($request->get('start')));
                $Calen->setEnd(new \DateTime($request->get('end')));
                $form = $this->createForm(new CalendrillerType(), $Calen);
                if ($this->container->get('request')->isXmlHttpRequest()) {
                        if ('POST' == $request->getMethod()) {
                       $form->bind( $request );                
            if ( $form->isValid( ) ) {
 
                $data = $form->getData();
 
                 $em->persist($data);
                  $em->flush();
                $response['success'] = true;
 
              }else{
 
                $response['success'] = false;
                $response['cause'] = 'whatever';
 
              }
 
              return new JsonResponse( $response );
            }
                  }
 
      }
le problème c'est que $data revoie NULL a tous les élément alors que quant je fais var_dump($request->get('title')) par exemple la request est valide.

analyse du post avec firebug:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
end	2013-09-05 00:00:00
start	2013-09-05 00:00:00
title	s
Source
title=s&start=2013-09-05 00:00:00&end=2013-09-05 00:00:00
reponse:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
 
{"success":false,"cause":"whatever"}
j'espère avoir été assez claire
Merci de votre compréhension