Skip to Content
เมนู
คุณต้องลงทะเบียนเพื่อโต้ตอบกับคอมมูนิตี้
คำถามนี้ถูกตั้งค่าสถานะ
1 ตอบกลับ
4946 มุมมอง

Hi,

I have a model with more than 15 fields. In this model I have `state` field which indicates if the record might be able to be modified or readonly.

Is there a convienient way to set all fields to `readonly` based on the state in my model,

a) in the view or
b) in the model itself.

I dont want to override the models `write` method since the fields on the frontend suggest the user that he can change the values. I event do not want to add `attrs="{'readonly':[('state','not','draft')]}"` to all the fields in my view!

I tried to add the above `attrs=...` to the `group` tags in the view, but that does not seem to work (V8 RC1).

Any suggestions for a handy way to handle my requirement?

Cheers!

อวตาร
ละทิ้ง
คำตอบที่ดีที่สุด

Hi..

You can set the state attribute in python columns... That is the fesible option to lock your record based on a state value..

อวตาร
ละทิ้ง
Related Posts ตอบกลับ มุมมอง กิจกรรม
3
ส.ค. 24
15860
6
ก.ย. 17
8250
11
ก.ย. 16
19709
1
มี.ค. 15
4471
2
มี.ค. 15
9969