Visible / hidden / editable flags do nothing


#1

Hi, is are there any working examples of visible / hidden / editable flags for form and grid fields? The following codes, despite appearing in the userguide and source files, do not work:

$this->addField('TEST', [
  'caption' => 'here is my caption', 
  'type'=>'text', 
  'required'=>true, 
  'ui'   => ['editable' => false, 'visible' => false, 'hidden' => true]
]);  /* the field is required and shows my caption, but is editable and visible  */

$myModel->getElement(‘TEST’)->ui[‘visible’] = false; /* field is still visible */

Thank you,


#2

Field visibility logic is one area which can be better defined.

The logic is mainly outlined here:

but it’s presence in the atk4/data is questionable. Perhaps there should be a mechanism in UI that determines if fields should appear on certain component.

The best way to work-around is simply to specify list of fields to your Grid/Form during setModel().

Another rule is that system fields are not displayed by default.

The rest deserves a bit of a “refactor”. Perhaps after we’re done with the fields here: https://github.com/atk4/data/pull/314


#3

I tried using a subset of fields in setModel() but that prevented them from appearing in the modal editing form. I was wanting to assign hidden + editable properties to a field, so that it would not appear in the grid but would appear when editing, as per https://groups.google.com/d/msg/agile-toolkit-devel/v2xVYsRqFpY/2mhPxSiBbU0J. I do understand though that thread was written regarding the old Agile Toolkit though :slight_smile:


#4

When using CRUD:

editable - field is editable in form
visible - field is visible in grid

So if you want field which is not visible in grid, but is editable in form, then: visible=false, editable=true.


#5

actually, you can define set of field for editing adding and listing separately.

http://agile-ui.readthedocs.io/en/latest/crud.html?highlight=crud#specifying-fields


#6

Works perfectly! Thank you! :slight_smile: