Welcome, Guest
Username: Password: Remember me

TOPIC: limit enumeration selected

limit enumeration selected 01 Aug 2012 13:09 #2951

  • LJ01
  • LJ01's Avatar
  • Offline
  • Senior Member
  • Posts: 78
  • Thank you received: 2
  • Karma: 0
Hi
i create an enumeration list, and i want that a user create only one register by enumeration
example, if y have enumeration with choix_1 and choix_2, i want a limit fior creat only one choix_1

is-it possible or developpement are needed ?

LJ
Ce sont les fils qui font les cordes
ingall-niger.org
The administrator has disabled public write access.

Re: limit enumeration selected 01 Aug 2012 13:23 #2952

  • admin
  • admin's Avatar
  • Offline
  • Administrator
  • Chef
  • Posts: 3711
  • Thank you received: 987
  • Karma: 140
Dev.

It is very specific.

To do this, there are several ways.
I think the best is to remove the enum values from the list at the loading of it, so the user cannot do any mistake.
And if you care about a security injection, you can process a second test before to save. (check() function)


TODO :
1. In you view, instance a model searching for all entries of the concerned user.
2. Browse every entry, and for each entry, read the associated enum value (loop)
3. In this loop, for each enum value found, remove it from your enum array list.

Is it clear ?

TODO in the check() function of your table : (very strong protection if you need it)
1. Instance the same kind of model searching for all previous entries of the user
2. stack in an array all the enums values
3. Use in_array() function to check if the enum value to add is in the array.

Of course, if you want to test this second code, you must disable the first one.

Giving you the code for all this is long, and I prefer also you search a bit by yourself.
You have the whole map.

EDIT : IT can work not only for enumerations, but also for lists, or watever datas.


Hope it helps.
Coding is now a piece of cake
Last Edit: 01 Aug 2012 13:24 by admin.
The administrator has disabled public write access.
The following user(s) said Thank You: VeCrea, edwardcox
Time to create page: 0.064 seconds

Get Started