Skip to content

Commit

Permalink
Fix dispatch View to use the new FieldHelper.php
Browse files Browse the repository at this point in the history
  • Loading branch information
Ioannis committed Sep 27, 2024
1 parent 7be2d7d commit bb01666
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 19 deletions.
25 changes: 7 additions & 18 deletions app/templates/Standard/dispatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
$tableName = \Cake\Utility\Inflector::tableize(\Cake\Utility\Inflector::singularize($this->name));

// $vv_template_path will be set for plugins
$templatePath = $vv_template_path ?? ROOT . DS . "templates" . DS . $modelsName;
$templatePath = $vv_template_path ?? ROOT . DS . 'templates' . DS . $modelsName;

$action_args['vv_actions'][] = [
'order' => $this->Menu->getMenuOrder('Default'),
Expand Down Expand Up @@ -75,34 +75,23 @@
</div>

<?php
// Set the Include file name
// Will be used by the unorderedList element below
$this->set('vv_fields_inc', 'dispatch.inc');
$this->set('vv_submit_button_label', __d('operation', 'continue'));

// 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();

print $this->Field->startControlSet(
modelName: $this->name,
action: $vv_action,
editable: true,
reqFields: [],
pluginName: $this->getPlugin()
);
// Form body
print $this->element('form/unorderedList');

// Inject the Petition ID into the form, though it will most likely
// still be available in the URL.
print $this->Form->hidden('petition_id', ['value' => $vv_petition->id]);

// Inject the token, if indicated.
if(isset($vv_token_ok) && $vv_token_ok && !empty($vv_petition->token)) {
print $this->Form->hidden('token', ['value' => $vv_petition->token]);
}

if(file_exists($templatePath . DS . "dispatch.inc")) {
include($templatePath . DS . "dispatch.inc");
}

print $this->Field->submit(__d('operation', 'continue'));

print $this->Form->end();

print $this->Field->endControlSet();
4 changes: 3 additions & 1 deletion app/templates/element/form/unorderedList.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
// $vv_fields_inc
// $vv_template_path
// $vv_field_types
// $vv_submit_button_label

?>
<ul id="<?= $vv_action . '_' . $this->name ?>" class="fields form-list">
Expand All @@ -53,7 +54,8 @@
if(!isset($suppress_submit) || !$suppress_submit) {
// The Submit element will be printed only if we are adding or updating, and if not
// suppressed by the field configuration
print $this->element('form/submit', ['label' => __d('operation', 'save')]);
$vv_submit_button_label = $vv_submit_button_label ?? __d('operation', 'save');
print $this->element('form/submit', ['label' => $vv_submit_button_label]);
}
?>
</ul>
Expand Down

0 comments on commit bb01666

Please sign in to comment.