First Project, A Few Questions

Hi all,

I’ve gone through the blog tutorials and read most of the excellent Yii1.1 and PHP5 by Jeffrey Winesett and am embarking on my first website built with Yii.

It’s a simple client site with a number of lead gen forms. I’ve built it in Yii primarily because of the lead gen forms and to learn more for my first real app with Yii.

The basic structure so far is a few static pages and 4 ways to generate a ‘lead’. Each method of generating a lead will require slightly different form feilds.

  1. Mail a Printed catalog request (a form on one page)

  2. Download a PDF catalog (a widget on most pages)

  3. Quote Request (a form on one page)

  4. Contact Form (a form on one page)

My question is:

Can I create one Lead model and display different forms based on a variable passed through to the lead/create form? Then use modrewrite rules for different page names

Or should I create different models for each and combine them somehow in one admin?

Thanks for your help!

I should mention that each type of lead will have different form elements required and displayed.

If all of the forms have different form elements then I would tend to lean toward separate forms. If the logic is similar in some areas then place that code in the main model.

Yes. That is the way it should be used. One model and multiple view pages as per the requirement. If you look at the blog example, and see the views\post folder, you would find multiple view files for the same model (Post).

Thanks guys,

I actually went the other way (creating separate classes) because the form elements required, validation and rules were going to be different.