Yii Framework Forum: Update Record , But Only Field Not Set - Yii Framework Forum

Jump to content

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

Update Record , But Only Field Not Set Rate Topic: -----

#1 User is offline   pippuccio76 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 137
  • Joined: 10-September 13

Posted 16 April 2014 - 02:28 PM

Hello I have a question for you, I have a db which we assume each record has 50 fields between which there is a field "name the first time will only set the first 5 fields (also named). Here comes the problem, by using a query before inserting or do an update would check if the name is already present here are 2 alternatives:
not-present: everything appears in the form with 50 fields
-present: everything appears but the form with the fields in the db already written in the form, and then do the update, and so far it would be easy. What I want is that the fields are already present in the db are shown but there is no way of being able to re-edit that perform the update of the new fields entered by the user and not be able to edit those in the db.
How do you think could be done?
thanks
0

#2 User is offline   jkofsky 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 536
  • Joined: 17-May 10
  • Location:Pensacola, Florida

Posted 16 April 2014 - 07:24 PM

View Postpippuccio76, on 16 April 2014 - 02:28 PM, said:

Hello I have a question for you, I have a db which we assume each record has 50 fields between which there is a field "name the first time will only set the first 5 fields (also named). Here comes the problem, by using a query before inserting or do an update would check if the name is already present here are 2 alternatives:
not-present: everything appears in the form with 50 fields
-present: everything appears but the form with the fields in the db already written in the form, and then do the update, and so far it would be easy. What I want is that the fields are already present in the db are shown but there is no way of being able to re-edit that perform the update of the new fields entered by the user and not be able to edit those in the db.
How do you think could be done?
thanks

I'm not sure what you are trying to do, but in the form you could check is $model->fieldX has a value and 'readonly'=>'readonly' the the htmlOptions array() OR you could display the value only
<div class="row">
   <?php echo $form->lableEx($model, 'fieldX'); ?>
   <?php if (isset($model->fieldX) {
      echo CHtml::encode($model->fieldX);
   } else {
      echo $form->textBox(($model, 'fieldX');
   } ?>
   <?php echo $form->error($model, 'fieldX'); ?>
</div>

Understand this is top of head, to give an idea.
Do, or do not. There is no 'try.' Jedi Master Yoda
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