sonata ecommerce - Impossible to invoke a method ("hasroute") on a null variable - sonata

I'm a fan of sonata projet, but setup e-commerce module is quite insane
I have created new product provider, i follow all theses steps https://sonata-project.org/bundles/ecommerce/master/doc/reference/tutorials/create-product.html#configuration-backoffice
product provider is ok
But when i click on it "`Impossible to invoke a method ("hasroute") on a null variable.
Twig\Error\RuntimeError:
Impossible to invoke a method ("hasroute") on a null variable.
at vendor/sonata-project/admin-bundle/src/Resources/views/Form/form_admin_fields.html.twig:613
at twig_get_attribute(object(Environment), object(Source), null, 'hasroute', array('list'), 'method', false, false, false, 613)
(var/cache/dev/twig/1a/1a9bdba03ad1424df284f8c527d3514c85448a804e11ed9ad4d5ad856f76a77a.php:2037)
at __TwigTemplate_257b0cad492d880883cd5a7582c74613fa66ee34ccb1a1c2088d411013c1176f->block_sonata_type_model_list_widget(array('value' => null, 'attr' => array('class' => ''), 'form' => object(FormView), 'id' => 's60956d878485a_image', 'name' => 'image', 'full_name' => 's60956d878485a[image]', 'disabled' => false, 'label' => 'form.label_image', 'label_format' => null, 'multipart' => false, 'block_prefixes' => array('form', 'text', 'sonata_type_model_list', '_s60956d878485a_image', 'sonata_product_admin_product_sonata_type_model_list', 'sonata_product_admin_product_image_sonata_type_model_list', 'sonata_product_admin_product_image_sonata_type_model_list_image'), 'unique_block_prefix' => '_s60956d878485a_image', 'row_attr' => array(), 'translation_domain' => null, 'label_translation_parameters' => array(), 'attr_translation_parameters' => array(), 'cache_key' => '_s60956d878485a_image_sonata_type_model_list', 'errors' =>
Sonata config
$ /d/wamp64/bin/php/php7.3.5/php.exe bin/composer.phar info sonata*
sonata-project/admin-bundle 3.98.2 The missing Symfony Admin Generator
sonata-project/block-bundle 3.23.1 Symfony SonataBlockBundle
sonata-project/cache 2.0.1 Cache library
sonata-project/classification-bundle 3.16.0 Symfony SonataClassificationBundle
sonata-project/comment-bundle 3.3.1 Integrate the FOSCommentBundle in the Sonata Project
sonata-project/core-bundle 3.20.0 Symfony SonataCoreBundle (abandoned)
sonata-project/datagrid-bundle 3.3.0 Symfony SonataDatagridBundle
sonata-project/doctrine-extensions 1.12.0 Doctrine2 behavioral extensions
sonata-project/doctrine-orm-admin-bundle 3.34.0 Integrate Doctrine ORM into the SonataAdminBundle
sonata-project/easy-extends-bundle 2.5.0 Symfony SonataEasyExtendsBundle
sonata-project/ecommerce 3.5.2 E-Commerce solution provided by Sonata
sonata-project/entity-audit-bundle 1.3.1 Audit for Doctrine Entities
sonata-project/exporter 2.6.2 Lightweight Exporter library
sonata-project/form-extensions 0.1.2 Symfony form extensions
sonata-project/formatter-bundle 4.5.0 Symfony SonataFormatterBundle
sonata-project/intl-bundle 2.10.1 Symfony SonataIntlBundle
sonata-project/media-bundle 3.31.1 Symfony SonataMediaBundle
sonata-project/media-orm-pack 1.0.0 A pack for SonataMediaBundle with ORM support
sonata-project/notification-bundle 3.12.0 Symfony SonataNotificationBundle
sonata-project/seo-bundle 2.13.0 Symfony SonataSeoBundle
sonata-project/timeline-bundle 3.7.0 Integrates SpyTimelineBundle into Sonata
sonata-project/twig-extensions 0.1.1 Sonata twig extensions
sonata-project/user-bundle 4.11.1 Symfony SonataUserBundle
please Help

I had the same issue;
you need to create an admin for the related child entity present in the parent admin.
Can you paste your Entities, Admin and service.yaml files?

Related

Backpack for Laravel 'phone' field not working

I am using Backpack for Laravel to create an admin panel, however I am unable to make the 'phone' field show up as it is in the docs.
I have the Pro version, everything is up to date:
LARAVEL VERSION:
v9.45.0
BACKPACK VERSION:
5.4.11
Here is the field definition in the controller:
CRUD::addField([
'name' => 'telephone',
'label' => 'Telephone',
'type' => 'phone',
'config' => [
'onlyContries' => ['bd', 'cl', 'in', 'lv', 'pt', 'ro'],
'initialCountry' => 'cl',
'separateDialCode' => true,
'nationalMode' => false,
'autoHideDialCode' => false,
],
'wrapper' => [
'class' => 'col-md-4',
],
]);
The 'telephone' column in the database is varchar(20). I also tried with a phone column unsignedBigInt but it also resulted in the exact same behaviour.
Furthermore the above field does not go through the request validation, if that could be a hint as to what might be happening.
there is probably some misconfiguration that is breaking the field on your side, as I've just tested and everything seems to be working:
Possible causes that I could think from the top of my head are:
Don't have the minimum required PRO version: composer show backpack/pro should give you the installed version, the minimum required for phone field is 1.4.
Need to re-publish backpack assets. php artisan backpack:publish-assets
Field is not in fillable property of the model and/or isn't a fake field.
Let me know if you were able to solve it.
Cheers

Add Entity Reference to Drupal 8 Form Field?

How can users add products to a simple plugin config using an autocomplete field?
I tried to use Config Entity but it looks the same as Form API (and I can't use entity fields there).
I was able to do this in Drupal 8 using the form API and the entity_autocomplete type.
$form['stories'] = [
'#type' => 'entity_autocomplete',
'#target_type' => 'node',
'#title' => $this->t('Stories'),
'#description' => $this->t('Select some stories.'),
'#default_value' => $default_entities,
'#tags' => TRUE,
'#selection_settings' => array(
'target_bundles' => array('page', 'article'),
),
'#weight' => '0',
];
Use webform - there is an entity reference field.
This won't be useable for your purpose .. but you can check the source for sake.

choice_translation_domain not working in symfony 2.7

I just upgraded my project to Symfony 2.7. One of the features why I wanted to upgrade as soon as possible, was the choice_translation_domain option for form fields.
But somehow there are still more then 3000 warnings for missing translations.
Here is how I added one field where the translation is already handled by doctrine:
$builder->add('product', 'entity', array(
'class' => 'MyProject:Product',
'required' => false,
'multiple' => false,
'empty_value' => '',
'choice_translation_domain' => false,
'label' => 'label.product',
'query_builder' => function(EntityRepository $er) {
return $er->createQueryBuilder('product')
->orderBy('product.title', 'ASC');
},
));
In translation debugging, I still see, that Symfony tries to translate the already translated product titles.
My problem was that we overwrite the default form_div_layout from Symfony.
So I had to change our custom form layout .twig file in order to make the option choice_translation_domain work.

ZfcUserDoctrineMongoODM Configuration examples

I am trying to configure ZendFramwork 2 to use MongoDB as the storage for user Authentication.
I already have installed what I believe are the correct modules and have a correctly installed instance of ZF2 running on Nginx. I also have an instance of Mongo running and I am already using this for another project. The modules declaration in application.config.php looks like this
'modules' => array(
'Application',
'ZfcBase',
'ZfcUser',
'ZfcUserDoctrineMongoODM',
'DoctrineModule',
'DoctrineMongoODMModule'
)
Documentation is a bit thin on how to configure the system to get it working. Can anyone provide any code fragments around configuring the database settings to allow Mongo to run with ZfcUser, this is where I am at a loss now.
Any help, clues or cheat sheets would be greatly appreciated.
Darren Breeze
Have a look at Doctrine Mongo ODM module readme https://github.com/doctrine/DoctrineMongoODMModule :
copy
vendor/doctrine/doctrine-mongo-odm-module/config/module.doctrine-mongo-odm.local.php.dist
into your application's config/autoload directory, rename it to
module.doctrine-mongo-odm.local.php and make the appropriate changes.
With this config file you can configure your mongo connection, add
extra annotations to register, add subscribers to the event manager,
add filters to the filter collection, and drivers to the driver chain.
So you have something like this at your autoload config:
<?php
return array(
'doctrine' => array(
'connection' => array(
'odm_default' => array(
'server' => 'localhost',
'port' => '27017',
// 'connectionString' => null,
// 'user' => null,
// 'password' => null,
// 'dbname' => null,
// 'options' => array()
),
),
....
'configuration' => array(
'odm_default' => array(
... 'default_db' => 'myappdb',
)
)
So tune it and try to register at user/register. Collection name is user by default.

How to make own frontend-Forms with Magento 1.6.2

I have make a little Extension for Magento 1.6.2. I managed to write code in the backend-system to create a EAV Model to the database and I can write/read items from it like this tutorial: http://www.pierrefay.com/magento-admin-gridview-85
How can I use the following Forms in the frontendsystem, .. I have see there are dont classes like Mage_Adminhtml_Block_Widget_Form. I dont want to use own HTML constructions, want to get I want Magento look and feel. Have anyone a idea how to make own forms in magento frontend with magento classes?
class Extension_Name_Adminhtml_Printcatalog_Edit_General_Form extends Mage_Adminhtml_Block_Widget_Form
{
protected function _prepareForm()
{
$form = new Varien_Data_Form();
$this->setForm($form);
$fieldset = $form->addFieldset('printcatalog_form',
array( 'legend' => __('Allgemeine Informationen')));
$fieldset->addField('catalog_name', 'text',
array(
'label' => __('Katalogname'),
'class' => 'required-entry',
'required' => true,
'name' => 'catalog_name',
));
$fieldset->addField('release_date', 'text',
array(
'label' => __('Erscheinungsdatum'),
'class' => 'required-entry',
'required' => true,
'name' => 'release_date',
// 'image' => Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN).'/adminhtml/default/default/images/grid-cal.gif',
// 'format' =>
Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT),
));
if (Mage::registry('printcatalog_data'))
{
$form->setValues(Mage::registry('printcatalog_data')->getData());
}
return parent::_prepareForm();
}
}
?>
Not possible out of the box, all magento front-end forms are hard coded. As you can see in the class you provided it is part of the Adminhtml module (Mage_Adminhtml_Block_Widget_Form), which is for the administration dashboard within magento.
The amount of development to integrate a form class like in your code is not worth the time or flexibility of a hardcoded front-end form ... in most cases. If the majority of your continued development revolved around forms, then I'd reconsider building out abstract form classes to help in the creation of your forms via the controller.
On a higher note, Magento does provide a fairly decent javascript validation system for your front-end.
You should look into Zend_Form, which came around after Magento/Varien's original form implementation.