What's the difference between Model Field editable(), readonly(), system(), visible(), hidden().

212 views
Skip to first unread message

Imants Horsts

unread,
Oct 8, 2012, 9:36:56 AM10/8/12
to agile-too...@googlegroups.com
What is intended difference between editable, readonly, system, visible and hidden in Model Field ?
As far as I can tell, there are some glitches and I can fix at least some of them, but I'm not sure what exactly was meant with every one of these "switches".
Can you tell me that?

Imants Horsts

unread,
Oct 8, 2012, 9:39:22 AM10/8/12
to agile-too...@googlegroups.com
I'm especially interested in what was meant with readonly() and editable() and how they *should* differ.

Imants Horsts

unread,
Oct 8, 2012, 4:59:16 PM10/8/12
to agile-too...@googlegroups.com
I already made a fix for readonly() fields which as far as I understand was not fully developed till now.
But before posting updates in github I would like to hear your opinion about above question.

Romans Malinovskis

unread,
Oct 9, 2012, 3:26:01 AM10/9/12
to agile-too...@googlegroups.com
Hi.

This was not clearly defined from the very start :)  Let’s try to get a concept together all of us and then stick to it.


system - field will be loaded by model always , even if not present in actual fields. Setting system to true will also hide the field, but it can be un-hidden.
hidden - field does not appear in the grid, form etc unless specifically added or requested by actual fields
editable / visible - overrides hidden but for only particular widgets. E.g. if field is hidden, but editable it will appear on the form, but not in grid. Setting editable(false) will hide field from form even if it’s not hidden.
readonly - the field will appear on the editable form but will be displayed using read-only field.

none of the field actually impacts the ability of the model to save / load the actual fields when used directly. They are used by Controller_MVCForm, Controller_MVCGrid, etc. 

note: switches can have 3 values - true, false and undefined. Some switches change the value of other switches, such as system would hide field. Some fields may override the methods , such as Field_Expression would set editable=false by default and readonly would always return true.

This is just a concept which makes sense, it’s not 100% aligned to the current implementation. 


What is intended difference between editable, readonly, system, visible and hidden in Model Field ?
As far as I can tell, there are some glitches and I can fix at least some of them, but I'm not sure what exactly was meant with every one of these "switches".
Can you tell me that?

--
 
 

--
Romans is the author of a revolutionary Web Development Framework 
Agile Toolkit (www.agiletoolkit.org), which is offered under Open Source
License. Please show your support by raising awareness (tell your friends
about it) or referring any commercial web development projects towards
our skilled developer team (http://www.agiletech.ie/company/)

Here is a 25-minute video explaining why Agile Toolkit is awesome:



Imants Horsts

unread,
Oct 9, 2012, 8:18:16 AM10/9/12
to agile-too...@googlegroups.com
About READONLY field I believe it should be like this:

1) If you set Model->addField('something')->readonly(true), then it should automatically set display(array('form'=>'readonly')) (which can be changed later).

2) If you set Model->addField('something')->readonly(false), then it should automatically remove display(form=>readonly) (which can be changed later).

3) Model fields with readonly=true should be loaded in model, displayed in forms as text, but should not be saved back in database no matter what. Now they save empty (Null) values back when you're doing form->update() or model->save() because form physically don't have such fields, but they are in model, so model saves empty (or null) values back!

4) If you display field value as text in case of readonly, then you should add nl2br() function to correctly show textarea values which can contain new-lines which should be translated to <br> tags.

I have already fixed all of this regarding model->field->readonly fields for myself and it works fine for me. Should I pull a patch and you can take a look into it? I have not changed any functionality regarding editable, visible, system and hidden (for now).

Romans Malinovskis

unread,
Oct 9, 2012, 6:00:10 PM10/9/12
to agile-too...@googlegroups.com

About READONLY field I believe it should be like this:

1) If you set Model->addField('something')->readonly(true), then it should automatically set display(array('form'=>'readonly')) (which can be changed later).

2) If you set Model->addField(‘something')->readonly(false), then it should automatically remove display(form=>readonly) (which can be changed later).

The problem here is that not all fields would display OK.  I’d prefer setting the property readonly=true to the HTML element which will result in a regular input field but withouth the editing capability. Also it should avoid loading the field from POST

There is already way to use the readonly field type and it’s exactly as you illustrated.

3) Model fields with readonly=true should be loaded in model, displayed in forms as text, but should not be saved back in database no matter what. Now they save empty (Null) values back when you're doing form->update() or model->save() because form physically don't have such fields, but they are in model, so model saves empty (or null) values back!

4) If you display field value as text in case of readonly, then you should add nl2br() function to correctly show textarea values which can contain new-lines which should be translated to <br> tags.

I have already fixed all of this regarding model->field->readonly fields for myself and it works fine for me. Should I pull a patch and you can take a look into it? I have not changed any functionality regarding editable, visible, system and hidden (for now).

we need a proper test-script for all of this into http://test-suite.agiletoolkit.org. This is a complex case. 

Imants Horsts

unread,
Oct 15, 2012, 6:17:31 AM10/15/12
to agile-too...@googlegroups.com
OK, but what should be the difference between:
A. model->addField('something')->type('readonly') and
B. model->addField('something')->type('line')->readonly(true) ???

Romans Malinovskis

unread,
Oct 15, 2012, 6:41:55 AM10/15/12
to agile-too...@googlegroups.com

OK, but what should be the difference between:
A. model->addField(‘something')->type('readonly') and

shouldn’t work. readonly is not a valid field format, it’s means of presentation

B. model->addField(‘something')->type('line')->readonly(true) ???

flag for configuring forms, forms can decide what to show

> C. model->addField(’something’)->display(array(‘form’=>’readonly’));

changes presentation of the field in a form, form will use the specified field type.

Imants Horsts

unread,
Oct 16, 2012, 1:26:11 PM10/16/12
to agile-too...@googlegroups.com
A works, because in MVCForm readonly is a legal field type like int or string. Not only meant for displaying purposes.
B and C looks almost the same to me.

I'll be back to this topic after some days/week. Right now I have to impress my client with his new software (only 1st commit to him) :))

Andrea Panattoni

unread,
Oct 19, 2012, 6:34:19 AM10/19/12
to agile-too...@googlegroups.com
In the mean time, 
what is the right way to make a field not editable??
I have a model with fields that are editable or not based on the form they are displayed.
Is there a way to do it using the above mentioned methods?

thanks,
Andrea

Romans Malinovskis

unread,
Oct 20, 2012, 9:29:16 AM10/20/12
to agile-too...@googlegroups.com
I've posted initial test-script for this case.. no methods yet!


Reply all
Reply to author
Forward
0 new messages