Yii Framework Forum: Extend cal with own attributes? - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Extend cal with own attributes? Rate Topic: -----

#1 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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?
0

#2 User is offline   EdoFre 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 46
  • Joined: 24-February 11
  • Location:Groningen, The Netherlands

Posted 25 March 2011 - 07:42 AM

Did you name it in the rules of your model?
Moi,
0

#3 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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
0

#4 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 25 March 2011 - 02:04 PM

You need change eventCal.js in the assets folder
        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(); ?>

0

#5 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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!
0

#6 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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.
0

#7 User is offline   FlyBot 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 63
  • Joined: 20-January 09
  • Location:Ukraine

Posted 28 March 2011 - 11:42 AM

View PostHummer, 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?
0

#8 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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'];
0

#9 User is offline   Hummer 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 25-March 11

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!
0

#10 User is offline   Andres 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 16
  • Joined: 18-July 11

Posted 02 October 2011 - 08:19 PM

View PostHummer, 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.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users