Tuesday, August 31, 2010

Re: Fixing form ID

I have a login form in my default layout (as opposed to its own
template file, and will probably be moving it to an element soon) but
here is the code in my default layout. I didn't have to make any
changes to any of the login code.

Also, it sounds like you made a login model and then baked that into a
controller and views (I'm guessing this is why you have forms with ids
of loginedit, loginadd, loginview etc... the login should generally be
actions in the users controller/model/classes (not sure on the term
I'm really looking for here). I recommend not using any baked code
when setting up the login using the auth components.

Anyway the form ID really doesn't matter, the name is the important
part and should match the model that has your usernames and passwords.

if ($this->here != "/users/login") {
echo $form->create('User', array('url' => array('controller' =>
'users', 'action' =>'login')));
echo $form->input('User.name', array('label'=>""));
echo $form->input('User.password', array('label'=>""));
echo $form->end('Login');
}

This is the identical form I used in login.ctp only encased in an if
so that it doesn't show up if we're on the stand alone login page.

I'd suggest going back over this section and follow it step for step.
http://book.cakephp.org/view/1543/Simple-Acl-controlled-Application


On Aug 30, 4:16 pm, Alexis Laporte <alexis.lapo...@gmail.com> wrote:
> Hello people,
>
> I'm new at this cake thing ; facing difficulties with FormHelper.
>
> Problem is : I use the helper in the layout, to output a login form
> (mail + password). Its html id changes all the time (depending upon
> the URL : its id is wheter LoginAddForm or LoginIndexForm or
> LoginEditForm, etc.). Thus, I can't get the POSTed inputs in my
> controller (since I don't know which id to use : $this-
>
> >data>['loginID????']['password'])
>
> What to do ? Any way of fixing the ID ? (the API did not help :().
>
> Thanks,
> Alexis.

Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions.

You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: