chg: [genericElement:fieldScaffold] Let cake's form helper decide the input type if not specified

pull/121/head
Sami Mokaddem 2022-12-08 15:50:03 +01:00
parent b121399304
commit 21c5601c29
No known key found for this signature in database
GPG Key ID: 164C473F627A06FA
1 changed files with 4 additions and 5 deletions

View File

@ -1,12 +1,11 @@
<?php <?php
if (is_array($fieldData)) { if (is_array($fieldData)) {
if (empty($fieldData['type'])) {
$fieldData['type'] = 'text';
}
$fieldTemplate = 'genericField'; $fieldTemplate = 'genericField';
if (!empty($fieldData['type'])) {
if (file_exists(ROOT . '/templates/element/genericElements/Form/Fields/' . $fieldData['type'] . 'Field.php')) { if (file_exists(ROOT . '/templates/element/genericElements/Form/Fields/' . $fieldData['type'] . 'Field.php')) {
$fieldTemplate = $fieldData['type'] . 'Field'; $fieldTemplate = $fieldData['type'] . 'Field';
} }
}
if (empty($fieldData['label'])) { if (empty($fieldData['label'])) {
if (!isset($fieldData['label']) || $fieldData['label'] !== false) { if (!isset($fieldData['label']) || $fieldData['label'] !== false) {
$fieldData['label'] = \Cake\Utility\Inflector::humanize($fieldData['field']); $fieldData['label'] = \Cake\Utility\Inflector::humanize($fieldData['field']);