collection_table - dynamic label

45 views
Skip to first unread message

paolo...@gmail.com

unread,
Nov 19, 2013, 4:29:10 AM11/19/13
to symfony2adm...@googlegroups.com
hi, 
I'm trying to give a dynamic label to a subform but I cann't understand how I can do. I have a main form called TSchedaMonitoraggio, and a subform called TVolatiliSorvoloSuolo. I wish that the label of each subform is the value of a field of TVolatiliSorvoloSuolo (eg id_volatili_sorvolo_suolo). how can I do?
thank you very much

/birdstrikeapp2a/src/Birdstrike/AppBundle/Resources/config/TSchedaMonitoraggio-generator.yml
 
   fields:
      TVolatiliSorvoloSuolos:
        label: _
        dbType:           collection
        formType:         collection_table
        addFormOptions: 
          sortable:  true
          sortable_field:  id_volatili_sorvolo_suolo
          type:           \Birdstrike\AppBundle\Form\Type\TVolatiliSorvoloSuolo\EditType
          allow_add:      true
          allow_delete:   true
          by_reference:   false
          options:
            label:          ??DYNAMIC LABEL??
            data_class:     \Birdstrike\AppBundle\Model\TVolatiliSorvoloSuolo

/birdstrikeapp2a/src/Birdstrike/AppBundle/Form/Type/TSchedaMonitoraggio/EditType.php

       $ids= $builder->getData()->getTVolatiliSorvoloSuolos(); 
       foreach ($ids as $k=>$v){
      $builder->add( 'TVolatiliSorvoloSuolos'.$k, 'collection_table', array( 'allow_delete' => true,  'by_reference' => false,  'sortable' => true,  'sortable_field' => 'id_volatili_sorvolo_suolo',  'type' => new              \Birdstrike\AppBundle\Form\Type\TVolatiliSorvoloSuolo\EditType(),  'options' =>   array(  'label' => $v->getIdVolatiliSorvoloSuolo(),    'data_class' => '\\Birdstrike\\AppBundle\\Model\\TVolatiliSorvoloSuolo',  ),  'label' => '_',  'translation_domain' => 'Admin',));
   }

error:
Neither the property "TVolatiliSorvoloSuolos0" nor one of the methods "getTVolatiliSorvoloSuolos0()", "isTVolatiliSorvoloSuolos0()", "hasTVolatiliSorvoloSuolos0()", "__get()" or "__call()" exist and have public access in class "Birdstrike\AppBundle\Model\TSchedaMonitoraggio"

paolo...@gmail.com

unread,
Nov 28, 2013, 12:19:17 PM11/28/13
to symfony2adm...@googlegroups.com, paolo...@gmail.com
nobody can help me???

Cesar Cardenas

unread,
Dec 2, 2013, 12:03:15 AM12/2/13
to symfony2adm...@googlegroups.com, paolo...@gmail.com
you need to create the getTVolatiliSorvoloSuolos() fuction in your Entity, im just guesing but this error comes becouse TVolatiliSorvoloSuolos is not part of the class TSchedaMonitoraggio
maybe if you show yor Entity we can give a beter response,
other option is get all id whit doctrine (if tou are using doctrine) the code for this is

 $ids= $this->getDoctrine()
        ->getRepository('AcmeStoreBundle:YOURENTITY')
        ->findAll();

Message has been deleted

paolo...@gmail.com

unread,
Dec 2, 2013, 3:06:23 AM12/2/13
to symfony2adm...@googlegroups.com, paolo...@gmail.com
First of all, thank you for helping me. 
I'm using propel. It is already present in the model function TVolatiliSorvoloSuolos(), but are instead called functions TVolatiliSorvoloSuolos0(), TVolatiliSorvoloSuolos1(), TVolatiliSorvoloSuolos2(), etc., where the number at the end of the function corresponds to the value of the prototype name. attached the model and the form.
thanks
Paolo

 /birdstrikeapp2a/src/Birdstrike/AppBundle/Model/om/TSchedaMonitoraggio.php

public function getTVolatiliSorvoloSuolos($criteria = null, PropelPDO $con = null)
    {
        $partial = $this->collTVolatiliSorvoloSuolosPartial && !$this->isNew();
        if (null === $this->collTVolatiliSorvoloSuolos || null !== $criteria  || $partial) {
            if ($this->isNew() && null === $this->collTVolatiliSorvoloSuolos) {
                // return empty collection
                $this->initTVolatiliSorvoloSuolos();
            } else {
                $collTVolatiliSorvoloSuolos = TVolatiliSorvoloSuoloQuery::create(null, $criteria)
                    ->filterByTSchedaMonitoraggio($this)
                    ->find($con);
                if (null !== $criteria) {
                    if (false !== $this->collTVolatiliSorvoloSuolosPartial && count($collTVolatiliSorvoloSuolos)) {
                      $this->initTVolatiliSorvoloSuolos(false);
                      foreach ($collTVolatiliSorvoloSuolos as $obj) {
                        if (false == $this->collTVolatiliSorvoloSuolos->contains($obj)) {
                          $this->collTVolatiliSorvoloSuolos->append($obj);
                        }
                      }
                      $this->collTVolatiliSorvoloSuolosPartial = true;
                    }
                    $collTVolatiliSorvoloSuolos->getInternalIterator()->rewind();
                    return $collTVolatiliSorvoloSuolos;
                }
                if ($partial && $this->collTVolatiliSorvoloSuolos) {
                    foreach ($this->collTVolatiliSorvoloSuolos as $obj) {
                        if ($obj->isNew()) {
                            $collTVolatiliSorvoloSuolos[] = $obj;
                        }
                    }
                }
                $this->collTVolatiliSorvoloSuolos = $collTVolatiliSorvoloSuolos;
                $this->collTVolatiliSorvoloSuolosPartial = false;
            }
        }
        return $this->collTVolatiliSorvoloSuolos;
    }
EditType.php
BaseTSchedaMonitoraggio.php
Reply all
Reply to author
Forward
0 new messages