Yii Framework Forum: how to define a default textField value? - Yii Framework Forum

Jump to content

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

how to define a default textField value? Rate Topic: ***** 1 Votes

#1 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 401
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 23 December 2010 - 05:59 AM

how to define a default textField value?
I want to see a defaut textField value in a textField and fill the others textFields.
	<div class="row">

		<?php echo $form->labelEx($model,'text_name'); ?>
		<?php echo $form->textField($model,'text_name',array('size'=>45,'maxlength'=>45)); ?>

	</div>

Posted Image
0

#2 User is online   tri 

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

Posted 23 December 2010 - 06:18 AM

View Postfouss, on 23 December 2010 - 05:59 AM, said:

how to define a default textField value?
I want to see a defaut textField value in a textField and fill the others textFields.
	<div class="row">

		<?php echo $form->labelEx($model,'text_name'); ?>
		<?php echo $form->textField($model,'text_name',array('size'=>45,'maxlength'=>45)); ?>

	</div>



Initialize the 'text_name' property in your model
public text_name = '...';

/Tommy
Don't forget to read The Definitive Guide to Yii (1.1 en) (1.1 sv) (2.0 en) | The class reference (1.1) (2.0) has the details
1

#3 User is offline   fouss 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 401
  • Joined: 05-October 10
  • Location:Bamako Mali

Posted 23 December 2010 - 06:46 AM

I found a solution in this post link

thanks!
Posted Image
0

#4 User is offline   Maurizio Domba Cerin 

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

Posted 23 December 2010 - 06:59 AM

or

if that is an attribute of the model object... than after the $model= new model you just initialize that attribute

$model->text_name=...
Find more about me.... btw. Do you know your WAN IP?
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