I don't believe this is necessary in the first place.  Why are you
giving someone the ability to edit the form that shouldn't be?  That's
the first issue I see.  Secondly, why are you passing values to be
saved if you don't want them overwritten?  That's the 2nd issue.
Thirdly, why are you even rendering them as form elements rather than
simple text within a paragraph tag instead?  That'd be the third issue
I see.

Although you are accomplishing what you want to do, I don't believe
you should be trying to do it in the first place as a more elegant
(albeit possibly more difficult to grasp?) solution is available.

On Apr 29, 4:52 pm, "Dave Maharaj :: WidePixels.com"
<[email protected]> wrote:
> I figured it out.
>
> //list of possible keys
>                                  $keys =
> $this->User->$model_name->find('list', array('fields' => 'id', 'order' =>
> 'id ASC'));
>                                  debug($keys);
>
>                                 $submitted =
> $this->data[$model_name][$model_name];
>
> debug($this->data[$model_name][$model_name]);
>
>                                 $results = array_diff($submitted, $keys);
>                                 debug($results);
>
> So if a "evil" user tries to change the value in a form and submits, the
> value is checked against possible values in the databsae....if not found we
> know someone was doing something they should not have been doing.
>
> I am using this for a form that only has checkboxes so it works for me.
>
> Any flaws?
>
> Thanks,
>
> Dave
>
> -----Original Message-----
> From: Dave Maharaj :: WidePixels.com [mailto:[email protected]]
> Sent: April-29-09 6:14 PM
> To: [email protected]
> Subject: re: Compare Array
>
> I am trying to do the same type thing with comparing an array. I am using
> this for a security set up so a user can not change values of a form so I
> get the list of possible keys
>
> //list of possible keys
>      $keys = $this->User->$model_name->find('list', array('fields' => 'id',
> 'order' => 'id ASC'));
>      debug($keys);
>
> Array
> (
>     [1] => 1
>     [2] => 2
>     [3] => 3
>     [4] => 4
>     [5] => 5
>     [6] => 6
> )
>
>     // values submitted by user  
>     $submitted =  $this->data[$model_name][$model_name];
>     debug($this->data[$model_name][$model_name]);
>
> Array
> (
>     [0] => 3
>     [1] => 5
>     [2] => 6
>     [3] => 1
> )
>
>         //how to compare vales against submitted values?
>     $results = array_udiff_assoc($keys, array($submitted));
>     debug($results);
>
> But i need to compare the keys with the submitted data and that where i am
> stuck. I need to check that the submitted values have a match with the
> possible values in the database.
>
> Can someone point out my error or suggestions?
>
> Thanks,
>
> Dave
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to