Yii Framework Forum: How to change form code - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

How to change form code Rate Topic: -----

#1 User is offline   Ziad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 31-October 10
  • Location:London

  Posted 01 November 2010 - 09:31 AM

Hi,

What's the best way to change the way a form is generated by Gii? I want to change some of the classes and the way the error messages are displayed.

Thanks
0

#2 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 01 November 2010 - 10:06 AM

The css for the form are in css/form.css, you should accomplish to change as you wish just by editing this file.

All code that is in views/controllerId/_form can be customized, you should consider it like an example, not like an untouchable standard.

All widgets (or CHtml::something) can be customized with the property that are specified in the doc (see the CHtml or the widget you are using).
0

#3 User is offline   Ziad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 31-October 10
  • Location:London

Posted 01 November 2010 - 10:44 AM

Thanks for your response zaccaria. I wanted to change the markup actually, not just the css, should have made that clear. I realise I can edit the _form file but then I'd have to do that each time I generated a form and that would take away a little bit from the whole point of having the code generated so I was wondering if there was a way to customise the code that is generated without messing with the framework's code itself.
0

#4 User is offline   tri 

  • Elite Member
  • Yii
  • Group: Moderators
  • Posts: 1,651
  • Joined: 20-November 08
  • Location:Stockholm, Sweden

Posted 01 November 2010 - 12:20 PM

View PostZiad, on 01 November 2010 - 10:44 AM, said:

Thanks for your response zaccaria. I wanted to change the markup actually, not just the css, should have made that clear. I realise I can edit the _form file but then I'd have to do that each time I generated a form and that would take away a little bit from the whole point of having the code generated so I was wondering if there was a way to customise the code that is generated without messing with the framework's code itself.


Read the section "Customizing code templates". You may want to customize framework/gii/crud/templates/default/_form.php (and of course store it in a place specified by generatorPaths in your application config).
http://www.yiiframew...1/en/topics.gii

/Tommy

This post has been edited by tri: 01 November 2010 - 12:32 PM

Don't forget to read The Definitive Guide to Yii (en) (sv) | The class reference has the details
0

#5 User is offline   Ziad 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 28
  • Joined: 31-October 10
  • Location:London

Posted 01 November 2010 - 01:10 PM

Perfect! Thanks tri.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users