symfony-2.1

Symfony2 send form ajax

坚强是说给别人听的谎言 提交于 2019-12-05 15:57:18
问题 I'm trying to submit a form via ajax to update a field of an entity, but do not know how to retrieve the data from the controller: <form class="ajax" action="{{ path('ajax_setSocial') }}" method="post" {{ form_enctype(form) }}> <div class="editor"> {{ form_errors(form) }} <div class="editLabel pls">{{ form_label(form.ragSocial) }}</div> <div class="editField"> <div class="ptm"> {{ form_widget(form.ragSocial) }} {{ form_errors(form.ragSocial) }} </div> {{ form_rest(form) }} <div class="mtm">

Symfony 2.1 Doctrine filters (enable/disable)

随声附和 提交于 2019-12-05 15:48:43
I'm currently implementing Doctrine filters in my Symfony2.1 project with the following setup: <?php namespace Acme\Bundle\Entity; class Article { /** * @ORM\Column(type="string") */ private $status; ... } //app/config/config.yml doctrine: orm: filters: status: class: Acme\Bundle\Filter\StatusFilter enabled: false .... //src/Acme/Bundle/Filter/StatusFilter.php namespace Acme\Bundle\Filter; use Acme\Bundle\Entity\Status; class StatusFilter extends SQLFilter { public function addFilterConstraint(ClassMetadata $target, $alias) { $filter = $target->reflClass->implementsInterface('Acme\Bundle

How to administratively invalidate a session that used “Remember Me” option?

ⅰ亾dé卋堺 提交于 2019-12-05 14:41:58
I'm using Symfony 2.1.6 and PdoSessionStorage. I'm trying to add the same functionality that Facebook has to my application where you can show a user all the active sessions they have with the website (showing device type and location based on IP) and allow them to end any session if it looks suspicious. Deleting the record from the PdoSessionStorage table doesn't work as the record is re-created automatically by Symfony again as soon as I perform activity again in that session (instead of Symfony detecting that the session was already removed and thus forcing the user to re-authenticate). Is

Symfony2.1 - The option “em” does not exist when using DataTransformer

痞子三分冷 提交于 2019-12-05 13:13:47
I am using this cookbook recipe to add a data transformer in Symfon 2.1, but I am getting the following error, The option "em" does not exist. Known options are: "attr", "block_name",.... Is this still a valid way to send the entity manager over to the form type? $taskForm = $this->createForm(new TaskType(), $task, array( 'em' => $this->getDoctrine()->getEntityManager(), )); While I can't comment if that's the best way or not, I've always passed them to my task constructor as a hard dependency... Services services: my_bundle.form.type.task: class: Company\MyBundle\Form\Type\TaskType arguments:

Change WhiteOctober TCPDF bundle configuration values

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-05 12:49:20
I've started using the WhiteOctober TCPDF bundle in my symfony project but I can't figure out how to change the default configuration values, such as page format. I've tried putting that in my config.yml: white_october_tcpdf: tcpdf: k_tcpdf_external_config: true pdf_page_format: 'LETTER' pdf_author: 'Company Name' pdf_header_title: 'Order Confirmation' pdf_header_string: 'Company Name' pdf_header_logo: '%kernel.root_dir%/../web/images/logo.png' pdf_header_logo_width: '35' pdf_margin_header: 15 pdf_margin_footer: 15 pdf_margin_top: 25 pdf_margin_bottom: 25 pdf_margin_left: 25 pdf_margin_right:

Symfony2 authenticating users through a webservice

微笑、不失礼 提交于 2019-12-05 11:01:08
I'm currently dealing with Symfony2's Security component. I try to authenticate users against a webservice. To authenticate a user, I have to provide to the webservice a username and a password. I know that I've got to create a class that implements UserProvider. But the loadUserByUsername function doesn't fit my webservice needs : in order to authenticate a user, it ask for both username and password whereas the UserProvider's function only requires username. Here is a similar question to the problem I face : Symfony2 authentication without UserProvider I've been struggling on this problem

Assetic files in symfony are behind the firewall?

家住魔仙堡 提交于 2019-12-05 10:39:03
I have simple login page and security set up like this: firewalls: main: pattern: ^/ form_login: provider: fos_userbundle csrf_provider: form.csrf_provider use_referer: true always_use_default_target_path: true default_target_path: / logout: true anonymous: true access_control: - { path: ^/login$, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/register, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/resetting, role: IS_AUTHENTICATED_ANONYMOUSLY } - { path: ^/, role: ROLE_ADMIN } And in my base.html.twig file I have {% stylesheets '@BrStgCcBundle/Resources/public/css/bootstrap.css' %} <link

Login programmatically and stay logged in

偶尔善良 提交于 2019-12-05 06:53:04
I'm trying to implement single sign on access to a website using Symfony2. The authentication itself seems to work fine, but only for the initial page. On the next page that is loaded the user is not logged in anymore. Relevant code: $token = new UsernamePasswordToken($user, null, 'main', $user->getRoles()); $event = new InteractiveLoginEvent($request, $token); $this->get("event_dispatcher")->dispatch(SecurityEvents::INTERACTIVE_LOGIN, $event); $this->get("security.context")->setToken($token); return $this->redirect($this->generateUrl('sonata_user_profile_show')); First page (without the

Custom Authentication which doesn't need UserProvider

冷暖自知 提交于 2019-12-05 06:47:40
问题 I looked for a solution on the web for my configuration but I can't find something which satisfies my needs. So far, I have been working on this for 3 full days, and I can't make it works properly, I am sure there are several things that I didn't understand. I am developing my symfony application on the branch 2.1. To make this short. I have a webservice which I want to use for the authentication. This is the flow I want to implement: User submits credentials These credentials (username &

Symfony2 response - Clear cache headers on back button

南楼画角 提交于 2019-12-05 06:44:29
I have an issue with clearing my cache when back button is pressed. My header information is saying i'ts loaded from cache: Status Code:200 OK (from cache) My response is set to: $response = new Response; $response->expire(); $response->headers->addCacheControlDirective('must-revalidate', true); $response->headers->addCacheControlDirective('allow_reload', true); What am I doing wrong? None of the documentation methods seem to work... Taking advice from this article and setting listed Cache-Control directives worked for me - by pressing back button request to the server was always sent.