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

Showing 1-11 of 11 messages
What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/8/12 6:36 AM
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?
Re: What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/8/12 6:39 AM
I'm especially interested in what was meant with readonly() and editable() and how they *should* differ.
Re: What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/8/12 1:59 PM
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.
Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Romans Malinovskis 10/9/12 12:26 AM
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:



Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/9/12 5:18 AM
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).
Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Romans Malinovskis 10/9/12 3:00 PM

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. 

--
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:



Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/15/12 3:17 AM
OK, but what should be the difference between:
A. model->addField('something')->type('readonly') and
B. model->addField('something')->type('line')->readonly(true) ???
Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Romans Malinovskis 10/15/12 3:41 AM

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.


--
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:



Re: [atk4] What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Imants Horsts 10/16/12 10:26 AM
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) :))
Re: What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Andrea Panattoni 10/19/12 3:34 AM
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
Re: What's the difference between Model Field editable(), readonly(), system(), visible(), hidden(). Romans Malinovskis 10/20/12 6:29 AM
I've posted initial test-script for this case.. no methods yet!