Symfony 2.3: The "actions" extension is not enabled - symfony

I am currently updating a Symfony 2.1 project to Symfony 2.3 (and later to 3.4).
I just got the error message The "actions" extension is not enabled.. Can someone tell me where I can find the fault? Google could not help me unfortunately....
thanks
Anton

Take a look at the Symfony 2.1 to 2.2 upgrade guide:
FrameworkBundle
The render method of the actions templating helper signature and
arguments changed:
Before:
<?php echo $view['actions']->render('BlogBundle:Post:list', array('limit' => 2), array('alt' => 'BlogBundle:Post:error')) ?>
After:
<?php echo $view['actions']->render($view['router']->generate('post_list', array('limit' => 2)), array('alt' => 'BlogBundle:Post:error')) ?>
where post_list is the route name for the BlogBundle:Post:list controller, or if you don't want to create a route:
<?php echo $view['actions']->render(new ControllerReference('BlogBundle:Post:list', array('limit' => 2)), array('alt' => 'BlogBundle:Post:error')) ?>
Does this lead you on the right track?

Related

In cakephp 3 I got error Unexpected field in POST data

In cakephp 3 I got error Unexpected field in POST data.
Actually that field is not in my table, but I want to use in controller.
The Security Component in CakePHP is not forgiving. If you want to allow a field thru that should not go thru the Security Component hashing process, you need to use the unlockedField method that comes with the FormHelper class as such:
$this->Form->unlockField('field');
If this does not work, you will need to provide us with the pertinent code
I was getting the similar error in cakephp 3.4 I was using the simple html form and input fields. I was passing the input fields data in array. like below:-
<form action="" method="post">
<input name="data[1][category_1]" id="category_1">
</form>
Then i do some R&D and found that we need to use the cakephp form helper to create the form and its fields like below :-
In case of pass form data in array
<?= $this->Form->create($user, ['url' => ['controller' => 'Users', 'action' => 'saveOrder']]); ?>
<?= $this->Form->input("Data.1.category_1"); ?>
<?= $this->Form->end() ?>
In case of simple input fields you can do the code like below
<?= $this->Form->create($user, ['url' => ['controller' => 'Users', 'action' => 'saveOrder']]); ?>
<?= $this->Form->input("category"); ?>
<?= $this->Form->end() ?>
This work form me and resolve the error Unexpected field in POST data in cakephp 3.4

allow new methods in sandbox policy in twig (drupal 8)

I am getting this error when using the "field collection" module :
Twig_Sandbox_SecurityError: Calling "uri" method on a "Drupal\field_collection\Entity\FieldCollectionItem" object is not allowed in "themes/communitylife/templates/content/node.html.twig" at line 83. in Drupal\Core\Template\TwigSandboxPolicy->checkMethodAllowed() (line 99 of core/lib/Drupal/Core/Template/TwigSandboxPolicy.php).
the code that causes the problem is this one :
<div class=" title-col col-md-7">
<a href="{{file_url(node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.uri.value)}}" target="_blank"> <strong> {{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_description.value}}
<span class="file-type"> ({{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.uri.value | slice(-3) }} </span>, <span class="file-size"> {{node.field_pressemappe_bildmaterial[key].getFieldCollectionItem().field_presse_bild_file.entity.size }}) </span>
</strong></a>
</div>
what is the best way to fix this ? is it by adding (uri) to the allowed methods in the sandbox policy ? if yes then how I can do that ?
I read in the twig documentation that I can do something like this :
$policy = new Twig_Sandbox_SecurityPolicy($tags, $filters, $methods, $properties, $functions);
but I didn't understand how or where to put this code.
Thanks in advance
Drupal's twig sandbox policy (defined in core/lib/Drupal/Core/Template/TwigSandboxPolicy.php) reads from the global $settings array so you can define your own in your settings.php i.e.
// Override default twig method whitelist.
$settings['twig_sandbox_whitelisted_methods'] = [
// Defaults:
'id',
'label',
'bundle',
'get',
'__toString',
'toString',
// Additions:
'url',
];

Wordpress functions in Laravel

could anyone explain, is it possible include WP functions into Laravel blade.template?
I have WP installation and want create one folder for an app on Laravel. These functions i want include:
<?php require( '../wp-load.php' ); ?>
<?php get_header(); ?>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
How i can implement this feature?
Thx in advance!
1. Add WordPress to app/vendor
Download WordPress into the vendor folder (./vendor/wordpress)
User require in composer.json, see (3).
2. Find the function location
Check the Codex page for the function you need, let's say esc_url(), as you can see in that page, the function resides in wp-includes/formatting.php
3. Include the file containg the function
Include that file, use your composer.json file then run the command composer update
"require": {
...
"johnpbloch/wordpress": "4.*"
},
"autoload": {
...
...
...
"files": [
...
"wordpress/wp-includes/formatting.php"
]
},
4. Use the function in Blade
{{-- file: app/views/example.blade.php }}
{{ esc_html( 'A link' ) }}
This outputs:
<a href="http://www.example.com/">A link</a>

How do I use TrSteelCkEditorBundle in Symfony2?

I am new in the world of sf2 and I am trying to learn it.
I installed TrSteelCkEditorBundle with composer and now I am trying to get the editor in a view.
My bundle is active in the AppKernel.
As a beginner my question is:
What do I have to do to make it works?
I put this code and paste the value in the render
$form = $this->createFormBuilder()
->add('title', 'text')
->add('content', 'ckeditor', array(
'transformers' => array(),
))
->getForm();
And in the twig view i have line 6:
{{ form_widget(form) }}
but i'm getting an error :
An exception has been thrown during the rendering of a template ("Catchable Fatal Error:
Argument 1 passed to Symfony\Component\Form\FormRenderer::searchAndRenderBlock()
must be an instance of Symfony\Component\Form\FormView,
instance of Symfony\Component\Form\Form given, called in
/Applications/mamp/htdocs/Sf2/app/cache/dev/twig/5c/eb/e10823d760716de7f56b39640e79.php
on line 29 and defined in
/Applications/mamp/htdocs/Sf2/vendor/symfony/symfony/src/Symfony/Component/Form/FormRenderer.php
line 131") in amTestBundle:Default:index.html.twig at line 6.
If someone had a clue to resolve that it'll help me a lot.
Thank you.
The {{ form_widget(form) }} doesn't work because your $form variable is the form itself. In order to get Twig to create the widgets for it, you have to send it to the Twig template with:
$form->createView()
Here is an example of when you return in your controllerAction:
return $this->render(
'AcmeFooBundle:Acme:template.html.twig',
array('form' => $form->createView()) //Here you see the createView()
);

Symfony - access related table field from within a form

Is it possible to get a property of a related table of a field within a form? I'm trying to get a property called "getIdentifier" which belongs to the OriginalStone model class.
<?php foreach ($form['treatedStones'] as $fields):?>
<?php $fields['original_stone_id']->renderRow() ?>
<?php endforeach?>
I was hoping I could do something like:
<?php foreach ($form['treatedStones'] as $fields):?>
<?php $fields['original_stone_id']->getObject()->getIdentifier() ?>
<?php endforeach?>
Thanks
I assume treatedStones is an embedded doctrine form. Try $form->getEmbeddedForm('treatedStones')->getObject()->getOriginalStone()->getIdentifier()

Resources