Jump to content
Larry Ullman's Book Forums

Philip

Members
  • Content Count

    14
  • Joined

  • Last visited

  • Days Won

    3

Philip last won the day on November 4 2013

Philip had the most liked content!

Community Reputation

5 Neutral

About Philip

  • Rank
    Newbie
  1. I got it working by using listdata in the end. 'filter' => CHtml::listData(CourseEcts::model()->findAll(), 'id', 'ects_points'), I had to create a model for CourseEcts points and now I get a dropdown with the ects points which filters perfectly. It's not the most elegant of solutions as the dropdown is not based on the data in the gridview, but thats a separate issue that I'll come back to later. Thanks for all your help and suggestions! :-)
  2. Hi Edward, I think I have solved half the problem anyway. I found an article here which helped. I've gotten filtering to work on the related columns by adding properties to the CoursePeriod model. For example, to get textfield filtering working on Course.course_name and Course.ects_points I added the following properties in the CoursePeriod model: public $search_ects_points; public $search_course_name; I then added them to the rules ... search_ects_points, search_course_name', 'safe', 'on'=>'search'), in the search method I added the following $criteria->compare('course.ect
  3. Sorry, it can also be difficult to know how much to post without overwhelming the thread and I do appreciate your help! anyway as I've mentioned, I have two tables: CoursePeriod: id, course, term, year, start_date, end_date, other_non_important_logging_fields Course: course_id, course_name, department, course_level, ects_points CoursePeriod.course is a foreign key to Course.course_id My gridview is pulling from CoursePeriod and displays the following columns: Course.course_name, Course.course_level, CoursePeriod.CourseDates, Course.ects_points CourseDates comes from getCours
  4. The thing is that I am actually able to display ects points and I can also filter them using at text field, it's just the dropdown that isn't working. so this works: array( 'header' => 'ECTS', 'name' => 'course', 'value' => '$data->course->ects_points', but this doesn't array( 'header' => 'ECTS', 'name' => 'course', 'value' => '$data->course->ects_points', 'filter' => CHtml::dropDownList('Course[ects_points]', $m->course->ects_points, array(
  5. Thanks Edward, I think I am doing something wrong in my search() criteria and the name of the filter in gridview too. as a little back ground, my gridview is pulling from CoursePeriod, which has a foreign key in Course as basically courses are being reused every year. So CoursePeriod contains a course id call "course" which points to "course_id" in Course. I'd like to be able to add more information to the gridview such as course_name, ects_points and course level, all of which are contained in Course. I can get all the data to display using 'value'=>'$data->course->course_na
  6. Thanks Edward, It seems I must have made a mistake the first time around, as I got it working through using the tabular input tutorial. Basically my view looks something like this now: ... <?php foreach ($models as $i => $ccModel): ?> <div class="row"> <?php switch ($i) { case "c1p1": echo $form->labelEx($models[$i], $i); echo CHtml::activeDropDownList($models[$i], 'course', $data, array('name' => "CourseChoice[$i]", 'prompt' => 'Select
  7. Hi Edward My models Course and CoursePeriod have a One-To-Many relationship as defined in their relations: Course 'coursePeriods' => array(self::HAS_MANY, 'CoursePeriod', array('course' => 'course_id')), CoursePeriod 'course' => array(self::BELONGS_TO, 'Course', array('course' => 'course_id')), So basically one course can have many course periods. I think that the relations are ok, as it works fine when I don't explicitly set the filter, as I get a textfield which which filters when I enter 5 or 10. I get no records as expected if I put something else in.
  8. Hi guys In the book there is a tutorial showing how to create a filter in cgridview using a related model. This works great for me and I'm able to filter the list fine. However, in my instance, there can only ever be two things to filter '5' ECTS points and '10' ECTS points, so I'd rather have a dropdown menu. I've tried to implement it but I keep getting an error "Trying to get property of non-object" at $model->course->ects_points Here is the section in CGridView array( 'header' => 'ECTS', 'name' => 'course', 'value' =>
  9. Hi Edward Thank you for replying. I've come across that page while looking into this, but couldn't quite get it working. I'll give it another read and try again for safe measure. Thanks again
  10. Hi guys I've had this issue for a while now and I'm completely stuck. I've been reading the book and found the section on uploading multiple files and I'm just wondering how this could be adapted to my situation. I'm trying to use dropdown menus to insert course takes into the database. Basically a student can choose a 1st and 2nd choice course and on submit, 2 rows are inserted into the CourseChoices table. I can get the two rows inserted to the DB fine, but only if all the columns have been filled. Basically validation is not working at all and I'm at a loss at how to implement it. To g
  11. Ok I seem to have solved the issue for now, though I'm not sure if it is the correct 'Yii' way of doing things. What I did in the end was to create a private property in the the controller called $_modelData. Then I loaded the additional model in loadModel(), stored it in $_modelData and created a $modelData variable in the actionUpdate method. public function loadModel($id) { $model=Student::model()->findByPk($id); $this->_modelData = StudentData::model()->findByPk($id); // other stuff public function actionUpdate($id) { $model=$this->loadModel($id);
  12. Hi again Just a little update and a further question regarding the post. So I've finally gotten around to updating the database and have now implemented single table inheritance. I basically followed the advice in the the link provided by Larry in the updated database chapter - Yii - class table inheritance. Previously I had person, employee, student and teacher tables, but now I have a single user table with a column storing the user type. I then have a separate table storing addition student data. In Yii I have a model called User and another called Student which inherits from
  13. Hi Antonio and Larry, Apologies for taking so long to get back, I'm away in a summer house with no wifi and very limited data coverage. But I'm dealing with the withdrawal symptoms. :-) Anyway, thank you very much for your replies. @Antonio, thank you for posting your table structure. It is actually very similar to what I am dealing with here. Having a single user table would be ideal, however I can understand why the tables are split up between person, student and employee, as the developer probably wanted to ensure that certain properties can only be assigned to students. Once
  14. Hi all, Just wondering if anybody would have a suggestion for this. I'm new to Yii but have been coding in PHP for quite some time. I've been tasked to rewrite an old application in work which has become a mess over time. It is written in loosely object oriented PHP and uses MySQL. I've recently bought the Yii Book and is seems very good so far. I do have one question and I've tried searching around for similar questions, but can't seem to get a definite answer. Basically the database is set up so that there is 'person' table which includes person_id, names and dates etc. Then there a
×
×
  • Create New...