Add saving of ticket type for subticket type. #676

This commit is contained in:
Korina Cordero 2022-06-02 13:12:23 +00:00
parent efd402acb1
commit 96ce1f81fa
2 changed files with 14 additions and 9 deletions

View file

@ -136,7 +136,7 @@ class SubTicketTypeController extends Controller
{
$subticket_type = new SubTicketType();
$this->setObject($subticket_type, $req);
$this->setObject($subticket_type, $req, $em);
// validate
$errors = $validator->validate($subticket_type);
@ -192,7 +192,7 @@ class SubTicketTypeController extends Controller
*/
public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, SubTicketType $subticket_type)
{
$this->setObject($subticket_type, $req);
$this->setObject($subticket_type, $req, $em);
// validate
$errors = $validator->validate($subticket_type);
@ -239,10 +239,15 @@ class SubTicketTypeController extends Controller
$response->send();
}
protected function setObject(SubTicketType $obj, Request $req)
protected function setObject(SubTicketType $obj, Request $req, EntityManagerInterface $em)
{
// get the ticket type id
$ttype_id = $req->request->get('ticket_type_id', 0);
$ttype = $em->getRepository(TicketType::class)->find($ttype_id);
// set and save values
$obj->setName($req->request->get('name'));
$obj->setName($req->request->get('name'))
->setTicketType($ttype);
}
protected function generateFormSets(EntityManagerInterface $em)

View file

@ -34,7 +34,7 @@
</div>
<form id="row-form" class="m-form m-form--fit m-form--label-align-right m-form--group-seperator-dashed" method="post" action="{{ mode == 'update' ? url('subticket_type_update_submit', {'id': subticket_type.getId()}) : url('subticket_type_add_submit') }}">
<div class="m-portlet__body">
<div class="form-group m-form__group row">
<div class="form-group m-form__group row no-border">
<label class="col-lg-3 col-form-label" data-field="name">
Name:
</label>
@ -48,16 +48,16 @@
Ticket Type:
</label>
<div class="col-lg-9">
<select class="form-control m-input" id="ticket-type" name="ticket_type">
<select class="form-control m-input" id="ticket-type" name="ticket_type_id">
{% for id, label in sets.ticket_types %}
{% if (id == "{{ subticket.getID() }}") %}
<option value="{{ id }}" selected>{{ label }}</option>
{% if subticket_type.getTicketType %}
<option value="{{ id }}"{{ subticket_type.getTicketType.getID == id ? ' selected' }}>{{ label }}</option>
{% else %}
<option value="{{ id }}">{{ label }}</option>
{% endif %}
{% endfor %}
</select>
<div class="form-control-feedback hide" data-field="ticket_type"></div>
<div class="form-control-feedback hide" data-field="ticket_type_id"></div>
</div>
</div>
</div>