Yii Framework Forum: ActiveInoutField with emty initial value. - Yii Framework Forum

Jump to content

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

ActiveInoutField with emty initial value. Rate Topic: -----

#1 User is offline   genady 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 9
  • Joined: 04-July 10

Posted 16 July 2010 - 09:44 PM

What is the recommended way to use ActiveInputField with empty initial value? The call expects $model and $attribute, initializes value to the attribute's value. I need initial blank field no meter what respected attribute actually holds. I see 2 options:

- point to the dummy attribute that not populated through database.
- or clear attribute value before rendering the form

Any other 'cleaner' options available?

thanks.
0

#2 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,013
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 17 July 2010 - 04:15 AM

Can you explain the context where you need this? You've already mentioned the 2 obvious options, maybe we can find something better, if we understand what you try to do (and why).
0

#3 User is offline   Maurizio Domba Cerin 

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

Posted 19 July 2010 - 02:48 AM

I don't see the point of displaying an empty input value if that attribute has some value (what will be the value of that attribute if the user leaves the form ie. cancels the input)... in my opinion you should clear the attribute value if you want to show empty attribute input...
Find more about me.... btw. Do you know your WAN IP?
0

#4 User is offline   Junior - df9 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 416
  • Joined: 24-May 09
  • Location:Brazil

Posted 19 July 2010 - 05:24 AM

I've not tested, but what if you put
$model->unsetAttributes();


in your controller/action, right after creating the model instance?

like

public function actionCreate()
{
     $model = new MyModel();
     $model->unsetAttributes();
}


this way Qiang solved the problem of empty initial values for filtering in CGridView

hope it helps!

regards!

:)
______________________________________
Junior
df9.com.br
Linux Registered User #364954
GNU/Linux: together we're ready!
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