MissingOptionsException: The required option "class" is missing - symfony

I am getting the above error when trying to use a entity field type in a form.
I am using Symfony 2.6.0.
My class has a category field defined as:
/**
* #ORM\ManyToOne(targetEntity="Category", inversedBy="parent")
* #ORM\JoinColumn(name="category_id", referencedColumnName="id")
*/
protected $category;
The category class is defined as:
/**
* #ORM\OneToMany(targetEntity="Parent", mappedBy="category")
*/
protected $parents;
My form type has definition for the category as:
->add('category', 'entity', array(
'class' => 'AppBundle:Category',
'property' => 'name'
In my controller I am calling it with:
->add('category', 'entity')
The stack trace is below:
Symfony\Component\OptionsResolver\Exception\MissingOptionsException: The required option "class" is missing.
at n/a
in \project\vendor\symfony\symfony\src\Symfony\Component\OptionsResolver\OptionsResolver.php line 757
at Symfony\Component\OptionsResolver\OptionsResolver->resolve(array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\ResolvedFormType.php line 109
at Symfony\Component\Form\ResolvedFormType->createBuilder(object(FormFactory), 'category', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy.php line 82
at Symfony\Component\Form\Extension\DataCollector\Proxy\ResolvedTypeDataCollectorProxy->createBuilder(object(FormFactory), 'category', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormFactory.php line 87
at Symfony\Component\Form\FormFactory->createNamedBuilder('category', 'entity', null, array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 106
at Symfony\Component\Form\FormBuilder->create('category', 'entity', array())
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 268
at Symfony\Component\Form\FormBuilder->resolveChildren()
in \project\vendor\symfony\symfony\src\Symfony\Component\Form\FormBuilder.php line 216
at Symfony\Component\Form\FormBuilder->getForm()
in \project\src\AppBundle\Controller\TheController.php line 78
at AppBundle\Controller\TheController->editAction('30', object(Request))
in line
at call_user_func_array(array(object(TheController), 'editAction'), array('30', object(Request)))
in \project\app\bootstrap.php.cache line 3008
at Symfony\Component\HttpKernel\HttpKernel->handleRaw(object(Request), '1')
in \project\app\bootstrap.php.cache line 2970
at Symfony\Component\HttpKernel\HttpKernel->handle(object(Request), '1', true)
in \project\app\bootstrap.php.cache line 3119
at Symfony\Component\HttpKernel\DependencyInjection\ContainerAwareHttpKernel->handle(object(Request), '1', true)
in \project\app\bootstrap.php.cache line 2364
at Symfony\Component\HttpKernel\Kernel->handle(object(Request))
in \project\web\app_dev.php line 28
Any help would be very much appreciated.
Jay

It looks like you have created a form class, but are recreating the form in the controller rather than using the form class.
In my controller I am calling it with:
->add('category', 'entity')
You should either use the same class and property options as you did in the form class, or better, use the form class in the controller instead of recreating the form.
$this->createForm(new ParentType(), $parent);

Related

Oracle APEX - Invalid lob when calling to APEX Apex_mail.send

I have a Oracle Database 18c Standard Edition 2 Release 18.0.0.0.0 server with Oracle apex 19 running on a Linux box.
I am testing send emails with templates build on Apex. If I run the below code I get a error
begin
Apex_mail.send(p_application_id => 100,
p_to => 'demo#example.com',
p_from => 'demo_1#example.com',
p_template_static_id => 'TEST',
p_placeholders => '{"count":1}');
end;
ORA-06502: PL/SQL: error : invalid LOB locator specified: ORA-22275 numérico o de valor
ORA-06512: en "SYS.DBMS_LOB", línea 727
ORA-06512: en "APEX_190100.WWV_FLOW_MAIL", línea 776
ORA-06512: en "APEX_190100.WWV_FLOW_MAIL", línea 849
ORA-06512: en "APEX_190100.WWV_FLOW_MAIL", línea 873
ORA-06512: en "APEX_190100.WWV_FLOW_MAIL_API", línea 88
ORA-06512: en línea 3
I've tested same code in other Oracle server without problem.
If I call to the overloaded function of APEX_mai.send as bellow, it work fine.
begin
apex_mail.send(p_to => 'demo#example.com',
p_from => 'demo1#example.com,
p_body => 'Main email text goes here',
p_subj => 'APEX_MAIL - Plain Text message');
Apex_Mail.push_queue;
end;
Note:
Application 100 and template "TEST" exists in my apex workspace
My question, what is the problem in my code when I use template?
I have tried sending an empty placeholder, but I get the same result
I found the problem, For some strange reason, the "text plain" template should not be empty, I added a "."(yes, a simple dot) in the template with plain text and it started working.

NotFoundHttpException in RouteCollection.php line 161 resource controller

I am using following code in routes/web.php
Route::resource('affiliate/account', 'Affiliate\AccountController',
[
'pSignup' => 'affiliate.signup',
'gSettings' => 'affiliate.settings'
]
);
Controller is in app/Http/Controllers/Affiliate/AccountController.php
I am getting following error.
NotFoundHttpException in RouteCollection.php line 161
Any suggestions, what is causing this error?

Warning: Missing argument 1 for mock

I'm trying to make a service mock:
$this->mocker->mockService(
'manager.mikrotik',
new AtoumAdapter(
'\MyBundle\Services\MikrotikManager'
)
);
I get this error:
Warning: Missing argument 1 for
mock\MyBundle\Services\MikrotikManager::__construct(), called in
vendor/rezzza/mock-extension/src/Adapter/AtoumAdapter.php on line 45
and defined in vendor/atoum/atoum/classes/mock/generator.php(183) :
eval()'d code line 22
Where is my mistake?
Now I resolve using orphanize:
$this
->mocker
->mockService(
'manager.mikrotik',
new AtoumAdapter(
'\MyBundle\Services\MikrotikManager',
function ($generator) {
$generator->orphanize('__construct');
}
)
);
Here class __construct:
public function __construct($em,$mikrotikIp, $mikrotikUser, $mikrotikPassword)

Drupal 7 - Add node edit form into a 'Simple page'

I'm trying to add the edit form of an existing node to a Basic page. Based on a given nid.
This problem seemed simple, however my attempt resulted in the following error report:
$node = node_load(array('nid' => 83));
$output = drupal_get_form($node->type .'_node_form', $node);
echo $output;
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->load() (line 175 of /home/PAE/www/paemanu/includes/entity.inc).
Warning: array_flip(): Can only flip STRING and INTEGER values! in DrupalDefaultEntityController->cacheGet() (line 388 of /home/PAE/www/paemanu/includes/entity.inc).
Notice: Trying to get property of non-object in eval() (line 3 of /home/PAE/www/paemanu/modules/php/php.module(80) : eval()'d code).
Notice: Undefined index: _node_form in drupal_retrieve_form() (line 806 of /home/PAE/www/paemanu/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function '_node_form' not found or invalid function name in drupal_retrieve_form() (line 841 of /home/PAE/www/paemanu/includes/form.inc).
Notice: Undefined variable: output in eval() (line 3 of /home/PAE/www/paemanu/modules/php/php.module(80) : eval()'d code).
Notice: Undefined index: user-project in drupal_retrieve_form() (line 806 of /home/PAE/www/paemanu/includes/form.inc).
Warning: call_user_func_array() expects parameter 1 to be a valid callback, function 'user-project' not found or invalid function name in drupal_retrieve_form() (line 841 of /home/PAE/www/paemanu/includes/form.inc).
I've been on this issue for many hours, any help is greatly appreciated.
Try this code:
$nid = 83;
$node = node_load($nid);
$type = $node->type;
module_load_include('inc', 'node', 'node.pages');
$form = drupal_get_form('node_edit_'.$type, $node);
render($form);

Symfony2 Shell.php error on production server

I get the following error in app_dev.php on my production server:
ErrorException: Notice: Undefined variable: output in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php line 59
in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php
line 59
at ErrorHandler->handle('8', 'Undefined variable: output', '/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php',
'59', array('command' => 'find')) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Shell/Shell.php
line 59
at Shell->testCommand('find') in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Adapter/AbstractFindAdapter.php
line 123
at AbstractFindAdapter->isSupported() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Adapter/GnuFindAdapter.php
line 30
at GnuFindAdapter->isSupported() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php
line 700
at Finder->searchInDirectory('/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Validator/Resources/translations')
in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/Finder/Finder.php
line 628
at Finder->getIterator() in /www/acme/www/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
line 555
at FrameworkExtension->registerTranslatorConfiguration(array('fallback'
=> 'pl', 'enabled' => true), object(ContainerBuilder)) in /www/acme/www/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
line 106
at FrameworkExtension->load(array(array('translator' => array('fallback' => 'pl'), 'secret' =>
'eea6ad638afadb62cd7bc360e98f7d3b', 'router' => array('resource' =>
'/www/acme/www/app/config/routing.yml', 'strict_requirements' =>
true), 'form' => true, 'csrf_protection' => true, 'validation' =>
array('enable_annotations' => true), 'templating' => array('engines'
=> array('twig')), 'trust_proxy_headers' => false, 'default_locale' => 'pl', 'session' => null), array('router' => array('resource' =>
'/www/acme/www/app/config/routing_dev.yml'), 'profiler' =>
array('only_exceptions' => false))), object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/MergeExtensionConfigurationPass.php
line 42
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/DependencyInjection/MergeExtensionConfigurationPass.php
line 39
at MergeExtensionConfigurationPass->process(object(ContainerBuilder)) in
/www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/Compiler/Compiler.php
line 119
at Compiler->compile(object(ContainerBuilder)) in /www/acme/www/vendor/symfony/symfony/src/Symfony/Component/DependencyInjection/ContainerBuilder.php
line 494
at ContainerBuilder->compile() in /www/acme/www/app/bootstrap.php.cache line 950
at Kernel->buildContainer() in /www/acme/www/app/bootstrap.php.cache line 859
at Kernel->initializeContainer() in /www/acme/www/app/bootstrap.php.cache line 571
at Kernel->boot() in /www/acme/www/app/bootstrap.php.cache line 614
at Kernel->handle(object(Request)) in /www/acme/www/web/app_dev.php line 29
Everything works fine on my localhost so it can be something wrong with the server configuration.
Hosting provider has turned PHP exec function off because of the security reasons.
That's why above error occurred.
Does anyone know if its possible to bypass exec function in Symfony2 - I mean if it's possible to run symfony2 on the server with exec function turned off?
I've got the same problem with my hosting, with php safe_mode off. Actually there is a todo, but I dont know when they will fix it.
// todo: find a better way (command could not be available)
exec('command -v '.$command, $output, $code);
as seen in Symfony\Component\Finder\Shell\Shell;

Resources