Example #1
0
 /**
  * {@ineritedDoc}
  */
 public function build()
 {
     if (!is_object($this->data)) {
         return $this;
     }
     $className = get_class($this->data);
     $propertyAccessor = $this->getPropertyAccessor();
     foreach ($propertyAccessor->getProperties() as $prop) {
         //no static property
         if ($prop->isStatic()) {
             continue;
         }
         //only if form type exists
         $formType = FormFactory::getFormType($className, $prop);
         if (!$formType) {
             continue;
         }
         //text domain
         if (!$formType->getPtd()) {
             $formType->setPtd($this->getFormType()->getPtd());
         }
         $name = $prop->getName();
         $value = $propertyAccessor->getPropertyValue($name, $this->data);
         $subForm = FormFactory::createForm($name, $formType, $value);
         $this->add($name, $subForm);
         $subForm->build();
     }
     return $this;
 }
Example #2
0
 /**
  * {@inheritdoc}
  */
 public function getFormType($propertyName, FormType $formType = null)
 {
     if ($propertyName == 'scope') {
         //get the form type associated on the model we want
         $userFieldsFormType = \PopCode\Framework\Form\FormFactory::getFormType('FacebookAWD\\Plugin\\Connect\\Model\\SubscriptionFieldsPermission', 'fields');
         //set the options
         $formType->setOptions($userFieldsFormType->getOptions());
     }
     return $formType;
 }