Welcome Guest, Not a member yet? Register   Sign In
How can I solve this logic?
#1

[eluser]theshiftexchange[/eluser]
Hey guys,

How can I solve this issue?

Summary: each user creates an 'event' for a particular day. They are allowed one event per day.

Currently my form runs a callback on the date field, and checks that the date has not been used. Thats pretty simple.

Now I'm trying to add an 'edit' page. The problem is that if I want to allow users to be able to 'change' the date, I need to check the date has not been used unless it is the same day as was previously selected.

I cant see a way to do this with callbacks - because you can only pass the single variable from the field.

I'm thinking I maybe need to use a hidden field... any ideas?
#2

[eluser]Thorpe Obazee[/eluser]
I did this for a course manager app. In it we stored datetime ranges which is very similar.

You just need to have a callback that queries the db(assuming you have a db) if there's an event on the particular date and whether it has the same ID as the event your editing.


what do you mean by: [quote author="theshiftexchange" date="1242991921"]

I cant see a way to do this with callbacks - because you can only pass the single variable from the field.

I'm thinking I maybe need to use a hidden field... any ideas?[/quote]
#3

[eluser]theshiftexchange[/eluser]
[quote author="bargainph" date="1242992829"]I did this for a course manager app. In it we stored datetime ranges which is very similar.

You just need to have a callback that queries the db(assuming you have a db) if there's an event on the particular date and whether it has the same ID as the event your editing.
[/quote]

How do I give the callback the ID but?

I'm trying to keep all my $config form_valadation in a seperate file; so I'm not sure how I can reference a variable in the $config file to use in the function?
#4

[eluser]Thorpe Obazee[/eluser]
I also use a config form_validation file when developing apps but I don't see how that affects your problem

The callback can access the uri segment, the input, and probably 'anything'.




Theme © iAndrew 2016 - Forum software by © MyBB