This topic contains 1 reply, has 2 voices, and was last updated by Mike Kudelya 6 years, 10 months ago.
- Topic
Hi Sir
I had a bundle(SmsBundle) and now I create new entity (SmsPanel) , generate it’s table then generate crud and controller ((generate:doctrine:crud)/**
* SmsPanel
* @ORM\HasLifecycleCallbacks()
* @ORM\Entity
* @ORM\Table(name=”sms_panel”)
*
*/
class SmsPanel
{
/**
* @var integer
*
* @ORM\Column(name=”id”, type=”integer”)
* @ORM\Id
* @ORM\GeneratedValue(strategy=”AUTO”)
*/
private $id;/**
* @var string
*
* @ORM\Column(name=”title”, type=”string”, length=255)
*/
private $title;/**
* Constructor
*/
public function __construct()
{}
/** @ORM\PrePersist */
public function onPrePersist()
{
$this->createdAt = new \DateTime(‘now’, new \DateTimeZone(‘UTC’));
$this->updatedAt = new \DateTime(‘now’, new \DateTimeZone(‘UTC’));
}/** @ORM\PreUpdate */
public function onPreUpdate()
{
$this->updatedAt = new \DateTime(‘now’, new \DateTimeZone(‘UTC’));
}/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}/**
* @param string $title
*/
public function setTitle($title)
{
$this->title = $title;
}/**
* @return string
*/
public function getTitle()
{
return $this->title;
}
}————————
part of SmsPanelController for create/**
* Creates a new SmsPanel entity.
*
*/
public function createAction(Request $request)
{
$entity = new SmsPanel();
$form = $this->createCreateForm($entity);
$form->handleRequest($request);if ($form->isValid()) {
$em = $this->getDoctrine()->getManager();
$em->persist($entity);
$em->flush();return $this->redirect($this->generateUrl(‘smspanel_show’, array(‘id’ => $entity->getId())));
}return $this->render(‘SmsBundle:SmsPanel:new.html.twig’, array(
‘entity’ => $entity,
‘form’ => $form->createView(),
));
}——————
in “new.html.twig” just put below code
{% extends ‘OroUIBundle:actions:update.html.twig’ %}
—–
SmsPanelTypeclass SmsPanelType extends AbstractType
{
/**
* @param FormBuilderInterface $builder
* @param array $options
*/
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add(‘title’)
;
}/**
* @param OptionsResolverInterface $resolver
*/
public function setDefaultOptions(OptionsResolverInterface $resolver)
{
$resolver->setDefaults(array(
‘data_class’ => ‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’
));
}/**
* @return string
*/
public function getName()
{
return ‘websys_bundle_smsbundle_smspanel’;
}
}—
but I get below error
A model for “WebSys\Bundle\SmsBundle\Entity\SmsPanel::title” was not foundStack Trace
in /home/demo/public_html/vendor/oro/platform/src/Oro/Bundle/EntityConfigBundle/Config/ConfigModelManager.php at line 223 –
$model = $this->findFieldModel($className, $fieldName);
if (!$model) {
throw new RuntimeException(
sprintf(‘A model for “%s::%s” was not found’, $className, $fieldName)
);
}
at ConfigModelManager ->getFieldModel (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/oro/platform/src/Oro/Bundle/EntityConfigBundle/Config/ConfigManager.php at line 374 +
at ConfigManager ->getId (‘form’, ‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/oro/platform/src/Oro/Bundle/EntityConfigBundle/Provider/ConfigProvider.php at line 87 +
at ConfigProvider ->getId (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/oro/platform/src/Oro/Bundle/EntityConfigBundle/Provider/ConfigProvider.php at line 120 +
at ConfigProvider ->getConfig (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/oro/platform/src/Oro/Bundle/EntityExtendBundle/Form/Guesser/ExtendFieldTypeGuesser.php at line 67 +
at ExtendFieldTypeGuesser ->guessType (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 49 +
at FormTypeGuesserChain ->Symfony\Component\Form\{closure} (object(ExtendFieldTypeGuesser))
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 97 +
at FormTypeGuesserChain ->guess (object(Closure))
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormTypeGuesserChain.php at line 50 +
at FormTypeGuesserChain ->guessType (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’)
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 99 +
at FormFactory ->createBuilderForProperty (‘WebSys\Bundle\SmsBundle\Entity\SmsPanel’, ‘title’, null, array())
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 109 +
at FormBuilder ->create (‘title’, null, array())
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 268 +
at FormBuilder ->resolveChildren ()
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormBuilder.php at line 216 +
at FormBuilder ->getForm ()
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Component/Form/FormFactory.php at line 39 +
at FormFactory ->create (object(SmsPanelType), object(SmsPanel), array(‘action’ => ‘/app_dev.php/smspanel/create’, ‘method’ => ‘POST’))
in /home/demo/public_html/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Controller/Controller.php at line 163 +
at Controller ->createForm (object(SmsPanelType), object(SmsPanel), array(‘action’ => ‘/app_dev.php/smspanel/create’, ‘method’ => ‘POST’))
in /home/demo/public_html/src/WebSys/Bundle/SmsBundle/Controller/SmsPanelController.php at line 68 +
at SmsPanelController ->createCreateForm (object(SmsPanel))
in /home/demo/public_html/src/WebSys/Bundle/SmsBundle/Controller/SmsPanelController.php at line 82 +
at SmsPanelController ->newAction ()
at call_user_func_array (array(object(SmsPanelController), ‘newAction’), array())
in kernel.root_dir/bootstrap.php.cache at line 2844 +
at HttpKernel ->handleRaw (object(Request), ‘1’)
in kernel.root_dir/bootstrap.php.cache at line 2818 +
at HttpKernel ->handle (object(Request), ‘1’, true)
in kernel.root_dir/bootstrap.php.cache at line 2947 +
at ContainerAwareHttpKernel ->handle (object(Request), ‘1’, true)
in kernel.root_dir/bootstrap.php.cache at line 2249 +
at Kernel ->handle (object(Request))
in /home/demo/public_html/web/app_dev.php at line 29 +
The forum ‘OroPlatform – Programming Questions’ is closed to new topics and replies.