This commit is contained in:
tianshujie
2024-03-27 11:06:48 +08:00
committed by liyang
parent dd685ec573
commit 20accdb1ed
2 changed files with 15 additions and 5 deletions
+4 -2
View File
@@ -94,8 +94,10 @@ class todo extends control
if(!empty($_POST))
{
$form = form::batchData($this->config->todo->batchCreate->form);
$todosData = $this->todoZen->beforeBatchCreate($form);
$form = form::batchData($this->config->todo->batchCreate->form);
$todosData = $this->todoZen->beforeBatchCreate($form);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
$todoIdList = $this->todo->batchCreate($todosData);
if(dao::isError()) return $this->send(array('result' => 'fail', 'message' => dao::getError()));
+11 -3
View File
@@ -230,13 +230,19 @@ class todoZen extends todo
*
* @param form $form
* @access protected
* @return object
* @return array|false
*/
protected function beforeBatchCreate(form $form): array
protected function beforeBatchCreate(form $form): array|false
{
$todos = $form->get();
foreach($todos as $todo)
foreach($todos as $rawID => $todo)
{
if($todo->end < $todo->begin)
{
dao::$errors["end[{$rawID}]"] = sprintf($this->lang->error->gt, $this->lang->todo->end, $this->lang->todo->begin);
continue;
}
$account = $this->app->user->account;
$todo->date = $this->post->futureDate ? FUTURE_TIME : $this->post->date;
$todo->account = $account;
@@ -251,6 +257,8 @@ class todoZen extends todo
unset($todo->switchTime);
}
if(dao::isError()) return false;
return $todos;
}