Ejemplo n.º 1
0
 public function field($params)
 {
     if (isset($params['attributes']['data-list'])) {
         // If class has parent, ignore loading of childs, they will be loaded using AJAX
         if (isset($params['attributes']['data-parent'])) {
             $params['options'] = false;
         } else {
             $listCode = $params['attributes']['data-list'];
             if (array_key_exists("sort-key", $params["attributes"])) {
                 $sortKey = $params["attributes"]["sort-key"];
             } else {
                 $sortKey = "name";
             }
             if (array_key_exists("sort-order", $params["attributes"])) {
                 $sortOrder = strtoupper($params["attributes"]["sort-order"]);
             } else {
                 $sortOrder = "ASC";
             }
             $list = $this->reference_list_repository->findOneBy(array('code' => $listCode));
             $elements = $this->reference_list_repository->getElementsByOrder($list->getId(), $sortKey, $sortOrder);
             if ($list !== null) {
                 $options = $elements;
                 $params['options'] = $options;
             }
         }
     }
     //classes du champ
     $class = 'input input-' . $params['type'];
     if (isset($params['attributes']['class'])) {
         $class = $params['attributes']['class'] . ' ' . $class;
     }
     if (!empty($params['attributes']['data-parent'])) {
         $class = 'child-list ' . $class;
     }
     $params['attributes']['class'] = $class;
     //classe(s) de validation
     if (isset($params['attributes']['validator'])) {
         $params['attributes']['class'] .= ' validate[' . $params['attributes']['validator'] . ']';
     }
     return $this->form_helper->renderTag(null, $params);
 }
Ejemplo n.º 2
0
 /**
  * Retrieve element options
  *
  * @param string $listCode
  * @return array mixed
  */
 public function getElementOptions($listCode)
 {
     $list = $this->reference_list_repository->findOneBy(array('code' => $listCode));
     $options = $list->getElements()->getValues();
     return $options;
 }