Jump to content
Larry Ullman's Book Forums

Best Place For A Form With No Model


Jonathon
 Share

Recommended Posts

Hi,

 

I've read the piece on forms. I am wanting to implement a feedback button that will appear on each page. I'm just thinking as there is no model where is the ideal place for the code for it to go? The SiteController is what i'm thinking, only because it's the default controller. Just wanted some thoughts.

 

Thanks

 

Jonathon

Link to comment
Share on other sites

I don't really follow Thomas, sorry. 

 

If I can explain it, I just have a feedback button that appears on every page. Currently, I decided to link this to a static page (feedback.php). But i'm not sure where I should put handling the submission, validation and sending the feedback to an email address?

Link to comment
Share on other sites

Ok. Then you should scratch my regard for a default model. Not sure where I was going with that anyway now that I think about it.

 

The submission and feedback should be handled by a controller, while the validation should be placed in a model using the rules() method. That method should be initialized in the controller action the submission is done to, with a method call to validate(). You should then send the feedback over email considering validation.

 

As you want this on every page, a default controller makes much sense.

 

Guess you should wait for Larry to confirm if you are unsure about my approach. I got to admit I'm not 100% sure about this one. The email could possible be a model to. It makes sense to me, but I'm not really that sure.

Link to comment
Share on other sites

I think this is being thought of as more complicated than it is (if I understand it). Although technically your feedback button is part of a form (as all buttons are), it's really just a link. In fact, you should use a link and style it with CSS to make it look like a button. Then what you're talking about for the actual feedback page is the same as the contact page created by yiic. Just edit and use that. 

 

Also, never make a static page with a form that has to be handled. A static page should be just that: unchanging, unresponsive display of information, without user input.

Link to comment
Share on other sites

Yes. I really bodged this one.

 

1. Create a simple link to the controller action

2. The controller should serve the form

3. That same form should recive the post request from the form

4. The controller should use a model to validate the post data

5. The controller should send the feedback email as appropriate. (As stated, I'm not sure where the email content belongs. Larry may clarify this.)

 

I think I'm back on safe ground now. Sorry for providing some bad suggestions here. Let a poor man rectify himself a little. :)

Link to comment
Share on other sites

 Share

×
×
  • Create New...