Add new merge hook to override default form values
This commit is contained in:
@@ -101,14 +101,18 @@ class Gantt extends Base
|
|||||||
{
|
{
|
||||||
$project = $this->getProject();
|
$project = $this->getProject();
|
||||||
|
|
||||||
$this->response->html($this->template->render('gantt/task_creation', array(
|
$values = $values + array(
|
||||||
'project' => $project,
|
|
||||||
'errors' => $errors,
|
|
||||||
'values' => $values + array(
|
|
||||||
'project_id' => $project['id'],
|
'project_id' => $project['id'],
|
||||||
'column_id' => $this->board->getFirstColumn($project['id']),
|
'column_id' => $this->board->getFirstColumn($project['id']),
|
||||||
'position' => 1
|
'position' => 1
|
||||||
),
|
);
|
||||||
|
|
||||||
|
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
||||||
|
|
||||||
|
$this->response->html($this->template->render('gantt/task_creation', array(
|
||||||
|
'project' => $project,
|
||||||
|
'errors' => $errors,
|
||||||
|
'values' => $values,
|
||||||
'users_list' => $this->projectUserRole->getAssignableUsersList($project['id'], true, false, true),
|
'users_list' => $this->projectUserRole->getAssignableUsersList($project['id'], true, false, true),
|
||||||
'colors_list' => $this->color->getList(),
|
'colors_list' => $this->color->getList(),
|
||||||
'categories_list' => $this->category->getList($project['id']),
|
'categories_list' => $this->category->getList($project['id']),
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ class Taskcreation extends Base
|
|||||||
'color_id' => $this->color->getDefaultColor(),
|
'color_id' => $this->color->getDefaultColor(),
|
||||||
'owner_id' => $this->userSession->getId(),
|
'owner_id' => $this->userSession->getId(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->response->html($this->template->render('task_creation/form', array(
|
$this->response->html($this->template->render('task_creation/form', array(
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ class Taskmodification extends Base
|
|||||||
|
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
$values = $task;
|
$values = $task;
|
||||||
|
$values = $this->hook->merge('controller:task:form:default', $values, array('default_values' => $values));
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->dateParser->format($values, array('date_due'));
|
$this->dateParser->format($values, array('date_due'));
|
||||||
|
|||||||
@@ -58,8 +58,28 @@ class Plugin extends Base
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Example to override default values for task forms:
|
||||||
|
|
||||||
|
```php
|
||||||
|
class Plugin extends Base
|
||||||
|
{
|
||||||
|
public function initialize()
|
||||||
|
{
|
||||||
|
$this->hook->on('controller:task:form:default', function (array $default_values) {
|
||||||
|
return empty($default_values['score']) ? array('score' => 4) : array();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
List of merging hooks:
|
List of merging hooks:
|
||||||
|
|
||||||
|
#### controller:task:form:default
|
||||||
|
|
||||||
|
- Override default values for task forms
|
||||||
|
- Arguments:
|
||||||
|
- `$default_values`: actual default values (array)
|
||||||
|
|
||||||
#### controller:calendar:project:events
|
#### controller:calendar:project:events
|
||||||
|
|
||||||
- Add more events to the project calendar
|
- Add more events to the project calendar
|
||||||
|
|||||||
Reference in New Issue
Block a user