-
Notifications
You must be signed in to change notification settings - Fork 3
Refactor fields.inc to be configuration only - first pass. (CFM-218) #342
base: develop
Are you sure you want to change the base?
Conversation
] | ||
], | ||
'SUBTITLE' => [ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a convention used to insert an h3 subtitle between groups of fields. It looks like this:
'SUBTITLE' => [
'subtitle' => __d('api_connector', 'field.ApiSources.push_mode')
]
// By default, the form will POST to the current controller | ||
// Note we need to open the form for view so Cake will autopopulate values | ||
print $this->Form->create($vv_obj); | ||
if(!empty($vv_alternate_template)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The controller can assert $vv_alternate_template to have a non-standard template inserted here. It will be rendered without the standard form (but one could be included in the alternate template). This is currently used to render the Petition view.
// We will output the standard Form (for add, edit, and view). | ||
// By default, the form will POST to the current controller. | ||
// Note we need to open the form for view so Cake will autopopulate values. | ||
if($this->Field->includesFileField($fields)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a simple test for whether or not we have a file field. If we do, we have to change the form encoding type to multipart/form-data. The function that does this (in FieldHelper) assumes we'll know the exact level of the configuration in the $fields[] array since this will be (marginally) faster than doing a recursive search through the whole array. We do this generically to support future plugins (and probably themes). At the moment, we only use a file field for SSH Key upload.
@@ -26,10 +26,18 @@ | |||
*/ | |||
|
|||
// This view does currently not support read-only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were numerous fields.inc files (particularly in plugins) that locked down the fields exclusively to "edit". Where this test existed, I left it in - returning when $vv_action !== 'edit'.
Do we want to keep these or remove them? This looks like:
// This view only supports edit
if($vv_action !== 'edit') {
return;
}
] | ||
] | ||
]; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The approach taken here to set up the verification_code_charset field in the beforeField block will not work because the php here is no longer being generated inside Cake's form element. We need to find a different way to accommodate what we are trying to do.
'postal_code', | ||
'country', | ||
'type_id' => [ | ||
// XXX fix fieldOptions - just make this flat |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to flatten the fieldOptions sub-array, and list its elements at the top level. (We did this in Match.) That has not yet been done here.
So this structure:
'type_id' => [
// XXX fix fieldOptions - just make this flat
'fieldOptions' => [
'default' => $vv_default_type
]
]
would become this structure:
'type_id' => [
'default' => $vv_default_type
]
// Include fields configuration for the form. This will typically include the $fields array. | ||
$fields = []; // Backstop the fields array: some configs have no fields. | ||
$fieldsFile = "fields.inc"; // This is the default. | ||
if(file_exists($templatePath . DS . 'fields-' . $vv_action . '.inc')) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a new convention:
if(file_exists($templatePath . DS . 'fields-' . $vv_action . '.inc')) {
// We have an action file override in the form of "fields-ACTION.inc". Use it.
$fieldsFile = 'fields-' . $vv_action . '.inc';
}
This allows us to follow a general convention for non-standard actions.
@@ -74,6 +75,24 @@ public function initialize(array $config): void { | |||
$this->setPrimaryLink(['external_identity_source_id']); | |||
$this->setRequiresCO(true); | |||
|
|||
// All the tabs share the same configuration in the ModelTable file | |||
// XXX Reenable when this doesn't throw an error (same error as https://todos.internet2.edu/browse/CFM-475 ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I attempted to add the subnavigation for API Sources config similar to File Sources, Sql Sources (etc). When this block is included it throws an error similar to what we see in https://todos.internet2.edu/browse/CFM-475
7e8d4ed
to
984681b
Compare
984681b
to
46b3261
Compare
No description provided.