The "form" extension is not enabled - sonata-admin

"form" extension is not enabled
I got the above error when i override listAction of Sonata Admin Bundle.
Could someone have the same problem ?

Use $twig->getExtension(FormExtension::class) instead of $twig->getExtension('form') where FormExtension is included by use Symfony\Bridge\Twig\Extension\FormExtension;

Related

Symfony4 Override FosUserBundle Template

I'm following this : https://symfony.com/doc/current/bundles/FOSUserBundle/overriding_templates.html
I found the default template inside vendor/friendsofsymfony/user-bunfle/views/layout.html.twig
The documentation is then saying to place your new layout template at app/Resources/FOSUserBundle/views/layout.html.twig. Thing is, in Symfony4 there is nore more app folder I think. How should I do that then ? Thanks
You are right, and this is because the documentation is not updated for Symfony 4. What you need to do is copy all the templates files from vendor/friendsofsymfony/user-bundle/Resources/views and put them in a directory you create in /templates/bundles/FOSUserBundle. You can then edit the files in your newly created directory which will override the default templates.
In Symfony4, you can override it by placing your template in src/Resources/FOSUserBundle/views instead of templates/bundles/FOSUserBundle (yes, sadly not in templates directory)
In Symfony 4.4 the right place to override the FOSUserBundle templates is :
app/Ressources/FOSUserBundle/views
This work perfect in my project

Eslint-plugin-react configuration docs

Something in the eslint-plugin-react docs isn't clear to me.
https://github.com/yannickcr/eslint-plugin-react
It says I should also specify settings that will be shared across all the plugin rules (picture below).
But it doesn't say where should I add those settings. Should I add it to the .eslintrc.json file as a top-level property? Where else could it be?
Yes, they mean your project ESLint config that is usually .eslintrc.json.
By settings they mean the Shared Settings in the config.

['type aliases' can only be used in a .ts file]

I use command react-native init "name project" then open vscode appear to have error message code. (image)
This is what you need to do with VS Code, observe the gif carefully
Steps to resolve error
1. Go to extension
2. Click on more (...) and select Show Built-in extension
3. Search "TypeScript and JavaScript Language Features" - yellow & blue icon
4. Click on Setting icon of extension and select Disable (workspace)
5. Click on Reload / Restart Required
If you are getting this in React Native its probably a known bug in VSCode, that when Google Flow (which competes with MS Typescript) is coded, shows errors erroneously mentioning Typescript.
Your current .js code is supposed to be preprocessed by Flow into another .js file with "proper" js.
So make sure Flow is installed and then disable the Typescript parsing support. Here's the official answer on the Flow installation webpage:
Set javascript.validate.enable option to false or completely disable
the built-in TypeScript extension for your project (see gif below)...
Otherwise, you may want to stay as is and just change your code as suggested by C2P1 on March 19, 2018 on the github issue 631
To disable the [js] parser (connected to Typescript),
In VSCode menu: File -> Preferences -> User settings, (or ctrl+,) and add the following line
"javascript.validate.enable": false,
This answer was completed after seeing Idan Dagan's answer (Not the accepted answer) here: js 'types' can only be used in a .ts file - Visual Studio Code using #ts-check
And here's an excellent albeit old page about setting up the react-native environment, from Hackernoon. (You also have the VSCode React-native-full plugin)
Just disable built-in extension for TypeScript in VSCode. On the VSCode Extensions choose "Show Built-in Extensions" and then search for "TypeScript and JavaScript Language Features", Click disable then reload the VSCode. It works for me
In VScode
Press
CTRL + SHIFT + P
Use this command
Open User Settings
copy and paste the next line in the search bar in settings
#ext:vscode.typescript-language-features
ready uncheck JavaScript validation
Helped me to resolve
To disable the [js] parser (connected to Typescript),
In VSCode menu: File -> Preferences -> User settings, (or ctrl+,) and add the following line
"javascript.validate.enable": false,
This is what you are looking for. Unfortunately I haven't Googled a proper solution but we have to disable some JS checking.
https://github.com/Microsoft/vscode-react-native/issues/631
I've solved this with a plugin for VSCode "Flow Language Support". It will control the errors of the code instead of the plug-in TS-JS (built-in plugin of VS Code). In Details of plugin, guides you how to disable the original plugin TS-JS VSCode.
instead of disabling Typescript and Javascript language features extension, you can go to the extension settings, find the option Javascript > Validate: Enable, and uncheck it to remove any warnings.

How to enable className autocomplete on custom jsx tags (aka react components)?

I'm very new to vscode but i've set up about all the things I need. One more thing that is quite missing is the autocomplete for className attribute on custom jsx tags (aka react components). It simply does not recommend anything when on a custom tag.
I've tried searching for any extension that does this but couldn't find any, am I missing something here?
As I know there is no way to show react attributes in autocomplete list for custom react tags.
But there is a way to add className attribute quickly by putting a dot and typing your class name then hitting tab. This will create the custom tag with the given class attribute.
To do this, you need to configure Emmet extension (It is a built-in extension)
Add these lines to your VS Code User Settings (or Workspace Settings) file:
"emmet.triggerExpansionOnTab": true,
"emmet.includeLanguages": { "javascript": "javascriptreact" }
If you are on Mac, you can quickly open the User or Workspace Settings file, by pressing
Shift ⇧ + Command ⌘ + P and typing into the Command Palette: >settings.json.
Official Documentation at VS Code Web Site
Related Issue on VS Code Github

How do I enable Webstorm intellisense for AngularJS when writing CoffeeScript

I have setup Webstorm to recognise and compile my coffeescript files.
I have installed the AngularJS plugin and can successfully write my controllers etc in plain old javascript.
When I try to write my angular related code in CoffeeScript however I do not get any IDE support: code-completion, intellisense etc.
As a sign that all is not well, the angular variable itself is not recognised, as shown in the image below.
Question: How do I enable support for AngularJS in CoffeeScript files?
Thanks
To fix the specific problem Unresolved variable or type angular you need to make sure the angular javascript libraries have been Enabled (see image below).
You do this via the WebStorm settings:
File -> Settings -> Javascript -> Libraries
Here is the relevant help section: Configuring JavaScript Libraries
With webstorm 10 you are going to go to the preferences window and from there select Languages & Frameworks > JavaScript > Libraries. Then click the download button, select TypeScript community stubs from the dropdown at the top of the list, find angular and click download and install.
If you are using jshint be sure to go to the jshint settings find the Predefined option and add angular:true to suppress warnings.
In WebStorm v.11
go to "Settings" -> "Plugins" -> "Browse repositories".
Search and install "Angular Templates".
Profit
Settings screenshot

Resources