[Solar-talk] Form submission help

Raymond Kolbe rkolbe at gmail.com
Sat Jul 21 21:41:51 CDT 2007


Paul,

I see your name everywhere in these classes ;) That's a lot of code
you have written..hehe...thanks!

Yes, what you explained did help...also I remember about the public
properties being included in the view automatically.

Now that I have the form itself working, would I just use
$this->_request to access the actual data from the form...such as:

public function actionChangePassword(){
    // check if the form was submitted
    if ($this->_isProcess('PASSWORDUPDATE')) {
        if($this->_request->post('passwd1') ==
$this->_request->post('passwd2')){
            // update the password in the database
        }
    }
}

That seems to work just fine but I didn't know/couldn't find another
way to access the data from the form this way.

Also as another side note, when doing:

if ($this->_isProcess('PROCESS_PASSWORDUPDATE')) {

This does not work and returns false but doing:

if ($this->_isProcess('PASSWORDUPDATE')) {

or

if ($this->_isProcess('passwordupdate')) {

works just fine.

Thanks again for all of the support!

--Raymond Kolbe

On 7/21/07, Paul M Jones <pmjones at ciaweb.net> wrote:
>
> On Jul 21, 2007, at 8:44 PM, Paul M Jones wrote:
>
> > On Jul 21, 2007, at 8:09 PM, Raymond Kolbe wrote:
> >
> >> Rodrigo,
> >>
> >> Thank you for your help!
> >>
> >> Note: Most of this email was written while I was trying to resolve my
> >> issue...I have since then resolved my issue but think it is worth
> >> mentioning my error and the solution to it.
> >>
> >> I suppose that echo $this->form()->auto($this->form)->fetch(); would
> >> make sense to grab the form.
> >>
> >> That being said, I did try taking _auth.php from the Solar_App_Base
> >> Layout directory and tried to replicate the way it is used there. It
> >> makes use of $this->form()...->fetch() and it outputs my form just
> >> fine. My issue at this point is to have my action pick up on the
> >> submission of data..
> >>
> >> Example (non-functioning/sample code):
> >>
> >> //------Vendor/App/Preferences.php-----//
> >> class Vendor_App_Preferences
> >>
> >> function actionChangePassword(){
> >>    $request = Solar::factory('Solar_Request');
> >>
> >>    // get the requested process
> >>    $process = $request->post('process');
> >>
> >>    // handle processes based on the localized button values
> >>    if ($process == $this->locale('PROCESS_UPDATEPASSWORD')) {
> >>        // I just wanted to change something to verify that the
> >> form is working
> >>        $this->layout_head['title'] = 'Updated your password';
> >>    }
> >> }
> >
> > I know you've solved it, but here's some background info that might
> > make things easier in future:
> >
> > * A request object already exists for your use; it's $this-
> > >_request.  Strangely, I don't expect you'll need it in common
> > cases, because you have access to the the request portions you need
> > through other means.  For example ...
> >
> > * To check a process submission, you can use $this->_isProcess
> > ('PROCESS_UPDATEPASSWORD').  That will do the locale translation
> > and $_request->post('process') value checking for you.  (Good on
> > you for doing the locale translation, by the way -- lots of folks
> > don't get that so quickly, and have trouble localizing their apps
> > later on.)
> >
> > So the revised version would be:
> >
> >     function actionChangePassword()
> >     {
> >        // handle processes based on the localized button values
> >        if ($this->_isProcess('PROCESS_UPDATEPASSWORD')) {
> >            // I just wanted to change something to verify that the
> > form is working
> >            $this->layout_head['title'] = 'Updated your password';
> >        }
> >     }
> >
> > (or use PROCESS_UPDATEPASSWORD, whichever you settled on at the end.)
>
> Whoops, I can go one better on that.  The _isProcess() method is a
> little smarter than I typed above.  You can actually do this:
>
>         if ($this->_isProcess('updatepassword')) { ...
>
> The _isProcess() method upper-cases the word and prefixes with
> PROCESS_ for you, then translates that as a locale key, so you don't
> need to see all-caps everywhere in your code.
>
>
>
> --
>
> Paul M. Jones  <http://paul-m-jones.com>
>
> Solar: Simple Object Library and Application Repository
> for PHP5.  <http://solarphp.com>
>
> Join the Solar community wiki!  <http://solarphp.org>
>
> Savant: The simple, elegant, and powerful solution for
> templates in PHP.  <http://phpsavant.com>
>
>
> _______________________________________________
> Solar-talk mailing list
> Solar-talk at lists.solarphp.com
> http://mailman-mail3.webfaction.com/listinfo/solar-talk
>


More information about the Solar-talk mailing list