Page 1 of 1
Extend cal with own attributes?
#1
Posted 25 March 2011 - 07:09 AM
I am new to the yii framework and is trying to extend the "cal" extension with my own attributes.
I added a new attribute "note" to my database table, the controller and the model but "cal" isn't able to save the event when i try to. I get no errors or anything. Shouldn't it be possible to add new attributes, og use a different database table as long as the original attributes are intact?
I added a new attribute "note" to my database table, the controller and the model but "cal" isn't able to save the event when i try to. I get no errors or anything. Shouldn't it be possible to add new attributes, og use a different database table as long as the original attributes are intact?
#3
Posted 25 March 2011 - 07:55 AM
The where no rules before i added these which doesn't change anything:
public function rules()
{
return array('id', 'user_id', 'title','allDay','start','end','editable','note');
}
The new one is called note!
I have added the attribute to the mainController for "cal" like all the others but it doesn't work
I can confirm that when i manually add information to the "note" attribute in the database the model contains the attribute note and it contains the right information, but i am not able to save the events
public function rules()
{
return array('id', 'user_id', 'title','allDay','start','end','editable','note');
}
The new one is called note!
I have added the attribute to the mainController for "cal" like all the others but it doesn't work
I can confirm that when i manually add information to the "note" attribute in the database the model contains the attribute note and it contains the right information, but i am not able to save the events
#4
Posted 25 March 2011 - 02:04 PM
You need change eventCal.js in the assets folder
and modify views/calendar/browse.php
eventDialogOK = function() { var data = { eventId: $("#EventCal_id").val(), title: $("#EventCal_title").val(), start: $("#EventCal_start").val(), end: $("#EventCal_end").val(), allDay: $('input[name=EventCal_allDay]').attr('checked'), editable: $('input[name=EventCal_editable]').attr('checked'), note: $("#EventCal_note").val() }
and modify views/calendar/browse.php
<div class="row"> <?php echo CHtml::label(Yii::t('Calendar', 'Editable'), "EventCal_editable"); echo CHtml::checkBox("EventCal_editable", true); ?> </div> <div class="row"> <?php echo CHtml::label(Yii::t('Calendar', 'Note'), "EventCal_note"); echo CHtml::checkBox("EventCal_note", true); ?> </div> <?php echo CHtml::endForm(); ?>
#5
Posted 27 March 2011 - 05:03 AM
It is still not working for me, i have add my attribute everywhere and it still dont save the events. I am using the calendar as a module not as a controller, is that ok? I have tried to use it as a controller but i dont understand how i make use of the calendar as a controller. How does that work? Thx in advance!
#6
Posted 28 March 2011 - 03:41 AM
I have now tried to extend "cal" both when running it as a module and as controller and nothing helps.
#7
Posted 28 March 2011 - 11:42 AM
Hummer, on 28 March 2011 - 03:41 AM, said:
I have now tried to extend "cal" both when running it as a module and as controller and nothing helps.
Do you modify actionUpdate in the controller as you need?
Which is the POST params into actionUpdate?
What is written in the runtime/application.log about?
#8
Posted 29 March 2011 - 03:08 AM
I do modify the actionUpdate method. Finally i found out that my new attribute "note" isn't a part of the post into actionUpdate for some reason? I dont quite get why it's missing!
From application.log:
Undefined index: note (C:\xampp\htdocs\calTest\protected\components\UICalendarController.php:190)
That is where i try to get the post value
$user_id = Yii::app()->user->getState('cal_uid');
$title = $_POST['title'];
$note = $_POST['note']; //The one i added
$start = $_POST['start'];
$end = $_POST['end'];
$allDay = ($_POST['allDay'] == 'true') ? 1 : 0;
$editable = ($_POST['editable'] == 'true') ? 1 : 0;
$eventId = $_POST['eventId'];
From application.log:
Undefined index: note (C:\xampp\htdocs\calTest\protected\components\UICalendarController.php:190)
That is where i try to get the post value
$user_id = Yii::app()->user->getState('cal_uid');
$title = $_POST['title'];
$note = $_POST['note']; //The one i added
$start = $_POST['start'];
$end = $_POST['end'];
$allDay = ($_POST['allDay'] == 'true') ? 1 : 0;
$editable = ($_POST['editable'] == 'true') ? 1 : 0;
$eventId = $_POST['eventId'];
#9
Posted 29 March 2011 - 03:39 AM
I finally solved the problem, i didn't know that i hat to delete the eventCal.js from assets folder before it copies the new one
Anyway, thanks for the help!

#10
Posted 02 October 2011 - 08:19 PM
Hummer, on 29 March 2011 - 03:39 AM, said:
I finally solved the problem, i didn't know that i hat to delete the eventCal.js from assets folder before it copies the new one
Anyway, thanks for the help!

hi Hummer, I have the same problem, could you post your code and explain where was changed...
thx a lot.
Share this topic:
Page 1 of 1