Преглед на файлове

Check if the method exists and add a more helpful message

Thomas Rabaix преди 13 години
родител
ревизия
a166c5cc0f
променени са 1 файла, в които са добавени 5 реда и са изтрити 1 реда
  1. 5 1
      Admin/AdminHelper.php

+ 5 - 1
Admin/AdminHelper.php

@@ -129,7 +129,7 @@ class AdminHelper
         $this->addNewInstance($form->getData(), $fieldDescription);
         $data[$childFormBuilder->getName()][] = $value;
 
-        $form = $admin->getFormBuilder($form->getData())->getForm();
+        $form = $admin->getFormBuilder()->getForm();
 
         // bind the data
         $form->bind($data);
@@ -151,6 +151,10 @@ class AdminHelper
 
         $method = sprintf('add%s', $this->camelize($mapping['fieldName']));
 
+        if (!method_exists($object, $method)) {
+            throw new \RuntimeException(sprintf('Please add a method %s in the %s class!', $method, get_class($object)));
+        }
+
         $object->$method($instance);
     }