Hi, I'm trying to set up a custom manipulator for a timesheet app. I don't have the code in front of me at the moment but I'll try to create a extremely simplified example (they'll be errors since I don't have Django on this computer to validate the code, but it's just to give you a better idea).
The custom view will display 7 days (Mon->Sun) of timesheets for entry. The model is for individual days so the view consolidates the entries. It should also display the timesheet details for the week in a edit inline (InlineObjectCollection?) The problems lie in the following areas: * Manipulator - edit_inline/InlineObjectCollection * Template - {% for ts_detail in form.timesheetdetails %} Does anyone know how I can acomplish this? Should I be subclassing timesheets.AddManipulator instead in my custom manipulator? Model -=-=- class Timesheet(meta.Model): timesheet_date = meta.DateField() start_time = meta.TimeField() end_time = meta.TimeField() class TimesheetDetail(meta.Model): timesheet = meta.ForeignKey(Timesheet, edit_inline=meta.TABULAR, num_in_admin=3, num_extra_on_change=1) job = meta.CharField(maxlength=50, core=True) no_of_hours = meta.TimeField() Manipulator -=-=-=-=-=- class TimesheetWeekAddManipulator(formfields.Manipulator): def __init__(self): self.fields = ( formfields.HiddenField(field_name="date_mon", is_required=True) formfields.TimeField(field_name="start_time_mon", is_required=True), formfields.TimeField(field_name="end_time_mon", is_required=True), formfields.HiddenField(field_name="date_tue", is_required=True) formfields.TimeField(field_name="start_time_tue", is_required=True), formfields.TimeField(field_name="end_time_tue", is_required=True), . . formfields.HiddenField(field_name="date_sun", is_required=True) formfields.TimeField(field_name="start_time_sun", is_required=True), formfields.TimeField(field_name="end_time_sun", is_required=True), ) ##TODO: edit_inline/InlineObjectCollection def save(self, new_data): # My save code goes here pass View -=-= def add_timesheet(request): manipulator = TimesheetWeekAddManipulator() if request.POST: new_data = request.POST.copy() errors = manipulator.get_validation_errors(new_data) if not errors: manipulator.do_html2python(new_data) return HttpResponseRedirect("/timesheet/success") else: errors = new_data = {} # Set the values for the HiddenFields - can't remember the code but it would be here! form = formfields.FormWrapper(manipulator=manipulator, data=new_data, error_dict=errors, edit_inline=True) return render_to_response('timesheet/add', {'form': form}) Template -=-=-=-= I've removed most of the stuff including error reporting so that it's easier to read. <form> <table> <thead> <tr> <td></td> <td>MON</td> <td>TUE</td> <td>WED</td> <td>THU</td> <td>FRI</td> <td>SAT</td> <td>SUN</td> </tr> </thead> <tbody> <tr> <td>Start</td> <td>{{ form.date_mon }}{{ form.start_time_mon }}</td> <td>{{ form.date_tue }}{{ form.start_time_tue }}</td> <td>{{ form.date_wed }}{{ form.start_time_wed }}</td> <td>{{ form.date_thu }}{{ form.start_time_thu }}</td> <td>{{ form.date_fri }}{{ form.start_time_fri }}</td> <td>{{ form.date_sat }}{{ form.start_time_sat }}</td> <td>{{ form.date_sun }}{{ form.start_time_sun }}</td> </tr> <tr> <td>End</td> <td>{{ form.end_time_mon }}</td> <td>{{ form.end_time_tue }}</td> <td>{{ form.end_time_wed }}</td> <td>{{ form.end_time_thu }}</td> <td>{{ form.end_time_fri }}</td> <td>{{ form.end_time_sat }}</td> <td>{{ form.end_time_sun }}</td> </tr> </tbody> </table> <table> <thead> <tr> <td>job</td> <td colspan="">hours</td> </tr> <tr> <td> </td> <td>MON</td> <td>TUE</td> <td>WED</td> <td>THU</td> <td>FRI</td> <td>SAT</td> <td>SUN</td> </tr> </thead> <tbody> {% for ts_detail in form.timesheetdetails %} <tr> <td>{{ ts_detail.job }}</td> <td>{{ ts_detail.no_of_hours_mon }}</td> <td>{{ ts_detail.no_of_hours_tue }}</td> <td>{{ ts_detail.no_of_hours_wed }}</td> <td>{{ ts_detail.no_of_hours_thu }}</td> <td>{{ ts_detail.no_of_hours_fri }}</td> <td>{{ ts_detail.no_of_hours_sat }}</td> <td>{{ ts_detail.no_of_hours_sun }}</td> </tr> {% endfor %} </tbody> </table> </form> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users -~----------~----~----~----~------~----~------~--~---