Yii Framework Forum: extra fields in form which are not in db - Yii Framework Forum

Jump to content

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

extra fields in form which are not in db Rate Topic: -----

#1 User is offline   Roopa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 29-October 10

Posted 29 October 2010 - 09:09 AM

my issue is i am having company,users tables.I will enter id,pwd in company form and it will store in users table.but company table will not contain pwd feild.Now when i write pwd field explicitly in company form it showing error like "Property "Company.pwd" is not defined".

How can i add fields in a form which are not in db
0

#2 User is offline   Maurizio Domba Cerin 

  • Yii - Yesss It Is !!!
  • Yii
  • Group: Yii Dev Team
  • Posts: 4,346
  • Joined: 12-October 09
  • Location:Croatia

Posted 29 October 2010 - 02:14 PM

*** Note ***

@Roopa please pay attention to post in the right sub-forum

this is the second one you post in Yii-powered application and is not related to that...

Thread moved to Genera Discussion for Yii 1.1.x
Find more about me.... btw. Do you know your WAN IP?
0

#3 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 29 October 2010 - 02:19 PM

I guess is in your form... use the following:

echo CHtml::passwordField('pwd','INITITAL_VALUE_IF_YOU_PUT_ANY');

And then on the controller you can get the posted value as simple as this:

$pwd = Yii::app()->request->getParam('pwd');

------------------------
If you look in CHtml class, you will see that there is a bunch of methods that you can use with or without model classes.
------------------------


Hope I helped somehow...
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
0

#4 User is offline   Roopa 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 6
  • Joined: 29-October 10

Posted 29 October 2010 - 11:06 PM

View PostAntonio Ramirez, on 29 October 2010 - 02:19 PM, said:

I guess is in your form... use the following:

echo CHtml::passwordField('pwd','INITITAL_VALUE_IF_YOU_PUT_ANY');

And then on the controller you can get the posted value as simple as this:

$pwd = Yii::app()->request->getParam('pwd');

------------------------
If you look in CHtml class, you will see that there is a bunch of methods that you can use with or without model classes.
------------------------


Hope I helped somehow...

Actually my issue is adding an extra field which is not in that particular model,i f write an extra field,then click on 'create company' then only it is showing error,if it is after entering details in company form i can manage,but before only it is showing,in public function __get($name) it is not accepting
0

#5 User is offline   Antonio Ramirez 

  • Elite Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 1,448
  • Joined: 04-October 10

Posted 01 November 2010 - 04:25 AM

View PostRoopa, on 29 October 2010 - 11:06 PM, said:

Actually my issue is adding an extra field which is not in that particular model,i f write an extra field,then click on 'create company' then only it is showing error,if it is after entering details in company form i can manage,but before only it is showing,in public function __get($name) it is not accepting


I am actually using the same approach in my current application and it works perfectly.

Maybe I didn't understood your question... Are you actually sharing a _form file view among your company and user models?
¿How long would it take for you to understand that you own nothing in this world?

www.ramirezcobos.com
www.2amigos.us
www.github.com/tonydspaniard
www.github.com/2amigos


Posted Image
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