symfony1

Join query in doctrine symfony

孤街醉人 提交于 2019-12-08 04:21:52
问题 I have two tables userdetails and blog question The schema is UserDetails: connection: doctrine tableName: user_details columns: id: type: integer(8) fixed: false name: type: string(255) fixed: false BlogQuestion: connection: doctrine tableName: blog_question columns: question_id: type: integer(8) fixed: false unsigned: false primary: true autoincrement: true blog_id: type: integer(8) fixed: false user_id: type: integer(8) fixed: false question_title: type: string(255) I am using one join

How to get all users routed to one module and one action on logon in Symfony?

只谈情不闲聊 提交于 2019-12-08 04:16:09
问题 This follows on from my other question I posted. I need to make it so that when anyone logs in they are redirected to a particular module - sfGuardUser and action isExistingUser . I know it is somehting to do with the routing, but I am absolutely clueless with this file, I can't make head nor tail of it, and none of the tutorials online are making any sense to me. The problem is complicated (I think) further by the fact that if someone logs out (clicking a link logout) their url in the

Accessing user session from a custom routing class

此生再无相见时 提交于 2019-12-08 01:15:53
问题 Is there some way to acces the user object from a custom routing class? I'd like to add a parameter when generating a url, and that parameter is inside the user session, so I need to access it. The only way I found to access is using the sfContext::getInstance()->getUser(), but it's known to be inefficient. Thanks! 回答1: I'd write it the way you mention - I've used that method in similar situations and never had an issue performance wise, and suspect you will be the same. Also, never heard

Symfony: How to change a form field attribute in an action?

不想你离开。 提交于 2019-12-07 20:38:48
问题 I've got a functioning form with a sfWidgetFormChoice that acts as a list of checkboxes. I'm able to set the checkboxes to "ticked" by default with the following: 'status' => new sfWidgetFormChoice(array('choices' => array(1, 2, 3), 'multiple' => true, 'expanded' => true), array('checked' => 'checked')) ... where the checkboxes are called "status" and the possible values are 1/2/3. However, because of something else, instead of ticking them all by default I'd like to be able to control the

sfWidgetFormChoice rendered as an unordered list

孤街醉人 提交于 2019-12-07 20:21:21
问题 I'm using symfony 1.4.3 Is there some way to render a sfWidgetFormChoice as an unordered list? In the API there is an option called 'renderer_class' but I can't find any documentation or example about it. Thanks! 回答1: take a look at lib/vendor/symfony/lib/widget/sfWidgetFormSelect.class.php for example. Basically, what you need to do is implement a class that extends sfWidgetFormChoiceBase and write a method render() therein. A minimal example would look like this: <?php class

Customize errors symfony

◇◆丶佛笑我妖孽 提交于 2019-12-07 19:49:19
问题 There are some "best practice" in Symfony to customize form errors? For exemple, if i would to show "Campo obligatorio" when the field is required. 1)How can i do that better way and independent from what forms call it? 2)How can i customize message 'An object with the same "%namefield" already exist.' ? Thanks updated sorry, but if i try to do 'invalid' how you said me... it print me the same error $this->setValidator('urlres', new sfValidatorString(array( 'min_length' => 6, ), array( 'min

Symfony sfDoctrineGuardPlugin custom login query

时光毁灭记忆、已成空白 提交于 2019-12-07 19:18:29
问题 I use symfony sfDoctrineGuardPlugin to manage authentication for both frontend users and backend users. It's fine, except that I don't want frontend users to be able to login to the backend app. I can setup credentials, but credentials are checked after a user gets authenticated. What I want is to have sigin in form to never validate for a user, that is not in a backend group. How can I do this? 回答1: I think I found a better solution. sfDoctrineGuard plugin has its own post validator that

Symfony sfWidgetFormChoice always invalid with multiple choices (checkboxes)

本小妞迷上赌 提交于 2019-12-07 18:55:18
问题 I have a weird problem with checkbox validation. It's always invalid... I have read a lot about this problem, but I couldn't find the solution... (I use array_keys in validation) So, here is my code: class NetworkDevicesAndInterfacesForm extends sfForm { public function configure() { $optionsArr = array('one' => 'One','two' => 'Two'); $this->setWidgets(array( 'devices' => new sfWidgetFormChoice(array( 'expanded' => true, 'multiple' => true, 'choices' => $optionsArr), array('class' =>

Extending sfDoctrineRecord in symfony

人盡茶涼 提交于 2019-12-07 16:57:36
问题 I've added some functionality to some of my instance classes in my symfony project that I want ALL of my instance classes to have. If I didn't have any qualms about editing the core symfony installation, I would just add my methods directly to the sfDoctrineRecord class. But I don't want to do that, of course, because my changes would break on upgrade, plus my changes wouldn't port well to other projects. If I want to add certain functionality to all my instance classes in symfony, what's the

Dynamic menu with symfony in template

人走茶凉 提交于 2019-12-07 13:08:07
问题 I'm building a symfony website and I've my own code to build dynamically a menu with subitems. Right now I print it with a bit of twig code inside the base.html.twig file (master layout). The problem is when I need to pass the array with the items of the menu. I'm actually passing it to the render method of a single controller but obvsiously when I switch page I get a non-existent variable. How can I have a single location to put my php code to build the menu array and execute it every time a