foreach ($positionForm->get('entities')->getData() as $elm) { | foreach ($positionForm->get('entities')->getData() as $elm) { | ||||
$this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::PRE_UPDATE, ['entity' => $entity]); | ||||
$entity = $repo->find($elm['id']); | $entity = $repo->find($elm['id']); | ||||
$entity->setPosition($elm['position']); | $entity->setPosition($elm['position']); | ||||
$this->em->persist($entity); | $this->em->persist($entity); | ||||
$this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | $this->dispatch(EasyAdminEvents::POST_UPDATE, ['entity' => $entity]); | ||||
$latsPos = $elm['position']; | $latsPos = $elm['position']; | ||||
} | } | ||||
//die(); | |||||
//die(); | //die(); | ||||
//to do récupérer les élements hors ligne et incrémenter position | //to do récupérer les élements hors ligne et incrémenter position | ||||
/*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { | /*foreach ($repo->findBy(array('status'=> false)) as $offlineEntity) { |
prototype = $('#form_entities').data('prototype'); | prototype = $('#form_entities').data('prototype'); | ||||
$('.lc-sortable tr.lc-draggable').each(function (index, li) { | $('.lc-sortable tr.lc-draggable').each(function (index, li) { | ||||
// instead be a number based on how many items we have | // instead be a number based on how many items we have | ||||
var newForm = prototype.replace(/__name__/g, index); | var newForm = prototype.replace(/__name__/g, index); | ||||
$(li).append(newForm); | $(li).append(newForm); | ||||
$(li).find('#form_entities_' + index + '_id').val($(li).data('id')); | $(li).find('#form_entities_' + index + '_id').val($(li).data('id')); | ||||
if ($('.lc-sortable').data('parent-position') !== '') val = $('.lc-sortable').data('parent-position') + '.' + index | |||||
else val = index; | |||||
if ($('.lc-sortable').data('parent-position') !== '') { | |||||
//Ajout d'un 0 initial pour les nuémros <10 | |||||
indexAsString = index.toString().padStart(2, '0'); | |||||
val = $('.lc-sortable').data('parent-position') + '.' + indexAsString | |||||
} else { | |||||
val = index; | |||||
} | |||||
$(li).find('#form_entities_' + index + '_position').val(val); | $(li).find('#form_entities_' + index + '_position').val(val); | ||||
}); | }); | ||||