Skip to content

Commit

Permalink
Merge pull request #22 from gfernandes410/dev
Browse files Browse the repository at this point in the history
[enhancement] Add validation for empty entity
  • Loading branch information
jalogut authored Nov 22, 2019
2 parents b7ebf41 + f7143d9 commit a0a4db6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions templates/crud/Controller/Adminhtml/${Entityname}/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public function execute()
);

try {

if($objectInstance->getData('identifier') == null)
$objectInstance->setIdentifier($this->generateRandomString());

$objectInstance->save();
$this->messageManager->addSuccessMessage(__('You saved this record.'));
$this->_getSession()->setFormData(false);
Expand Down
4 changes: 4 additions & 0 deletions templates/crudEAV/Controller/Adminhtml/${Entityname}/Save.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ public function execute()
);

try {

if($objectInstance->getData('identifier') == null)
$objectInstance->setIdentifier($this->generateRandomString());

$objectInstance->save();
$this->messageManager->addSuccessMessage(__('You saved this record.'));
$this->_getSession()->setFormData(false);
Expand Down

0 comments on commit a0a4db6

Please sign in to comment.