Digging a little more, I have found a solution for #2.
Doing a $this->User->invalidate('name', 'Invalid User'); has done the
trick. Now I can be sure that the user really exists. =)

If anyone out there has the solution for #1, i would appreciate that

Regards,
- LS

On Aug 1, 4:15 pm, LS <[EMAIL PROTECTED]> wrote:
> Hello, everyone...
>   I've looked everywhere, and I've still have a problem with
> validation (that even may be solved in another way)...
>   I have two tables. Users (id, created, modified, name, login,
> password) and Companies (id, created, modified, name, user_id).
>   I want an ajax search to fill the user_id in my companies table. I
> have tought in two ways of that:
>
> #1
> Make an ajax searchable field (the search must be with the users.name
> field only), that stores the user.id somewhere to pass to the
> company.user_id when submitting the form
>
> Since I havent found a solution, for that, I skipped to another
> approach
>
> #2
> In the ajax searcheable field, grab the name of the user (wich is
> unique in the table), check the users table to see if the name really
> exists, grab the id and move on...
>
> BUT, I tried to make a validation (in the controller) to check if the
> name really exists, and, if not, accuse an error and return the same
> view again. I havent found how to tell the view that there is a
> problem with the data submitted.
>
> I am using cake version 1.2.0.5427alpha.
> I have a Users model with no fancy stuff
> I have a Company model with no fancy stuff
> I have a Companies controller with index and add controllers.
>   Index lists the companies
>   Add prints the add company view if no data is passed to it. If any
> data is passed to it, it SIMPLY checks if the name of the user passed
> is valid (I havent even done any saving in the database yet).
>
> If anyone can help with either the problems above, I would be VERY
> MUCH grateful.
>
> Thanks!
> - LS


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" 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