Exemplo n.º 1
0
 /**
  * Creates a form to update a Orders Status entity.
  *
  * @param Orders $order The entity
  *
  * @return \Symfony\Component\Form\Form The form
  */
 private function createStatusForm(Orders $order)
 {
     $form = $this->createFormBuilder()->setAction($this->generateUrl('orders_status_update', array('id' => $order->getId())))->setMethod('PUT');
     $children = $order->getOrderState()->getAvailableStates();
     $companionsCount = $order->getOrderCompanions()->count() > 1 ? true : false;
     if (is_array($children)) {
         $postable = $this->isPostable($order->getId());
         foreach ($children as $key => $child) {
             if ("post" == $child->getKey() && false == $postable) {
                 unset($child);
                 continue;
             }
             if (("approved" == $child->getKey() || "rejected" == $child->getKey()) && $companionsCount) {
                 $form->add($child->getKey(), 'button', array('label' => $child->getName(), 'attr' => array('id' => 'state_' . $key, 'class' => 'ml-5 btn-group btn-' . $child->getBootstrapClass(), 'value' => $child->getKey(), 'data-toggle' => "modal", 'data-target' => "#approvalModal")));
             } else {
                 $form->add($child->getKey(), 'submit', array('label' => $child->getName(), 'attr' => array('id' => 'state_' . $key, 'class' => 'ml-5 btn-group btn-' . $child->getBootstrapClass(), 'value' => $child->getKey())));
             }
         }
     }
     return $form->getForm();
 }