Skip to content

Commit

Permalink
Merge pull request #11746 from aembler/misc-fixes-110223
Browse files Browse the repository at this point in the history
Misc fixes 110223
  • Loading branch information
aembler committed Nov 3, 2023
2 parents 828a33c + 92bcc20 commit 1c4569c
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ public function add()
$vs = \Core::make('helper/validation/strings');

$name = $sec->sanitizeString($this->request->request->get('name'));
$handle = $sec->sanitizeString($this->request->request->get('handle'));
$handle = $this->request->request->get('handle');
$plural_handle = $this->request->request->get('plural_handle');

if (!$vs->handle($handle)) {
$this->error->add(t('You must create a handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
$this->error->add(t('You must create a valid handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
} else {
$entity = Express::getObjectByHandle($handle);
if (is_object($entity)) {
Expand All @@ -44,15 +45,19 @@ public function add()
}
}

if (!$vs->handle($plural_handle)) {
$this->error->add(t('You must create a valid plural handle for your data object. It may contain only lowercase letters and underscores.'), 'plural_handle');
}

if (!$name) {
$this->error->add(t('You must give your data object a name.'), 'name');
}

if (!$this->error->has()) {
$entity = new Entity();
$entity->setName($this->request->request->get('name'));
$entity->setHandle($this->request->request->get('handle'));
$entity->setPluralHandle($this->request->request->get('plural_handle'));
$entity->setHandle($handle);
$entity->setPluralHandle($plural_handle);
$entity->setLabelMask($this->request->request->get('label_mask'));
$entity->setDescription($this->request->request->get('description'));
$entity->setIsPublished(false);
Expand Down Expand Up @@ -330,10 +335,11 @@ public function update($id = null)
$vs = \Core::make('helper/validation/strings');

$name = $sec->sanitizeString($this->request->request->get('name'));
$handle = $sec->sanitizeString($this->request->request->get('handle'));
$handle = $this->request->request->get('handle');
$plural_handle = $this->request->request->get('plural_handle');

if (!$vs->handle($handle)) {
$this->error->add(t('You must create a handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
$this->error->add(t('You must create a valid handle for your data object. It may contain only lowercase letters and underscores.'), 'handle');
} else {
$exist = Express::getObjectByHandle($handle);
if (is_object($exist) && $exist->getID() != $id) {
Expand All @@ -343,6 +349,15 @@ public function update($id = null)
}
}

if (!$vs->handle($plural_handle)) {
$this->error->add(
t(
'You must create a valid plural handle for your data object. It may contain only lowercase letters and underscores.'
),
'plural_handle'
);
}

if (!$name) {
$this->error->add(t('You must give your data object a name.'), 'name');
}
Expand Down Expand Up @@ -379,7 +394,7 @@ public function update($id = null)
*/
$entity->setName($name);
$entity->setHandle($handle);
$entity->setPluralHandle($this->request->request->get('plural_handle'));
$entity->setPluralHandle($plural_handle);
$entity->setLabelMask($this->request->request->get('label_mask'));
$entity->setDescription($this->request->request->get('description'));
$entity->setDefaultViewForm($viewForm);
Expand Down
2 changes: 1 addition & 1 deletion concrete/src/Entity/Express/Control/Control.php
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public function setIsRequired($is_required)
public function getDisplayLabel()
{
return $this->getCustomLabel() ?
$this->getCustomLabel() :
h($this->getCustomLabel()) :
$this->getControlLabel();
}

Expand Down

0 comments on commit 1c4569c

Please sign in to comment.