Alternative to CDetailView

Hello :slight_smile:

The view for one of models uses the $this->widget(‘zii.widgets.CDetailView’ approach to show an individual record. I wasn’t too keen on layout of this with its tables so I decided to code it directly into the HTML like so:




...

<div class="description">

<p><?php echo $model->description; ?></p>

</div>

...



Is there anything wrong with this approach? Does the widgit provide any security benefits that my way doesn’t?

Thanks

Jonny

Not really it just provides ease of use in that you don’t have to write lots of markup. Although you could have created a component to inherit the CDetailView and given it a custom name and created the custom markup in there. That way you could reuse it without lots of code duplication.

Thanks for that Jaggi, yeah I didn’t think of that, I’ll have a little bash at knocking up something to make it a bit a bit friendlier.

Thanks :slight_smile:

I rarely use CDetailView so I think your approach is fine. :)

Hi Jaggi,

I am new to Yii. Can you please give pointers as to how this component could be created?

Thank you!

Yeh CDetailView is pretty useless unless your doing a CMS. I think the approach I am going to take is to extend CDetailView and reuse that in future projects. Basically just try to use as much yii built in functionality as I can!!