Add saving of ticket type for subticket type. #676
This commit is contained in:
parent
efd402acb1
commit
96ce1f81fa
2 changed files with 14 additions and 9 deletions
|
|
@ -136,7 +136,7 @@ class SubTicketTypeController extends Controller
|
||||||
{
|
{
|
||||||
$subticket_type = new SubTicketType();
|
$subticket_type = new SubTicketType();
|
||||||
|
|
||||||
$this->setObject($subticket_type, $req);
|
$this->setObject($subticket_type, $req, $em);
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $validator->validate($subticket_type);
|
$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)
|
public function updateSubmit(Request $req, EntityManagerInterface $em, ValidatorInterface $validator, SubTicketType $subticket_type)
|
||||||
{
|
{
|
||||||
$this->setObject($subticket_type, $req);
|
$this->setObject($subticket_type, $req, $em);
|
||||||
|
|
||||||
// validate
|
// validate
|
||||||
$errors = $validator->validate($subticket_type);
|
$errors = $validator->validate($subticket_type);
|
||||||
|
|
@ -239,10 +239,15 @@ class SubTicketTypeController extends Controller
|
||||||
$response->send();
|
$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
|
// set and save values
|
||||||
$obj->setName($req->request->get('name'));
|
$obj->setName($req->request->get('name'))
|
||||||
|
->setTicketType($ttype);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function generateFormSets(EntityManagerInterface $em)
|
protected function generateFormSets(EntityManagerInterface $em)
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
</div>
|
</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') }}">
|
<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="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">
|
<label class="col-lg-3 col-form-label" data-field="name">
|
||||||
Name:
|
Name:
|
||||||
</label>
|
</label>
|
||||||
|
|
@ -48,16 +48,16 @@
|
||||||
Ticket Type:
|
Ticket Type:
|
||||||
</label>
|
</label>
|
||||||
<div class="col-lg-9">
|
<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 %}
|
{% for id, label in sets.ticket_types %}
|
||||||
{% if (id == "{{ subticket.getID() }}") %}
|
{% if subticket_type.getTicketType %}
|
||||||
<option value="{{ id }}" selected>{{ label }}</option>
|
<option value="{{ id }}"{{ subticket_type.getTicketType.getID == id ? ' selected' }}>{{ label }}</option>
|
||||||
{% else %}
|
{% else %}
|
||||||
<option value="{{ id }}">{{ label }}</option>
|
<option value="{{ id }}">{{ label }}</option>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</select>
|
</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>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue