symfony1

Symfony sfWidgetFormChoice always invalid with multiple choices (checkboxes)

安稳与你 提交于 2019-12-06 05:23:59
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' => 'checkbox')) )); $this->setValidators(array( 'devices' => new sfValidatorChoice(array( 'choices' => array_keys(

Symfony, jQuery.ajax() call, session variables lost

前提是你 提交于 2019-12-06 04:36:21
问题 I am writing a web app using Symfony 1.3. I have a problem with my session variables getting lost after I call an action via jQuery's $.ajax() call. Things happen in this order: An action sets the session variable like this: $this->getUser()->setAttribute('uploaded-files', $uploadedFiles); Then when the action calls the view component, the resulting HTML page contains the following call: $.ajax({ type: "POST", url: '<?php echo url_for("content/merge"); ?>', cache: false, success:

Detect language and redirect to subdomain on Symfony

孤街浪徒 提交于 2019-12-06 02:52:16
问题 I'm using Symfony 1.2.7. My web is in several languages, each of one is in a subdomain like en.example.com, es.example.com. If the user enters into example.com, I want to redirect him to his language. I also want to have support staging.example.com and redirect to es.staging.example.com and en.staging.example.com so I can test everything before the deployment. I have the following code that works both on index.php and frontend_dev.php. My question is, can you improve it? is there a better or

Perform some cleanup when deleting a record in Symfony/Doctrine

拜拜、爱过 提交于 2019-12-06 01:48:28
问题 Using Symfony 1.4.5 with Doctrine I have a model which includes an uploaded image as one of the columns - creating and updating the record is fine (using the doSave() method to deal with the upload and any changes to the file). The problem I'm having is if the record is deleted - I want it to remove the associated file as well. But I can't find anyway to do this after several hours of hunting through documentation and Google. Is there a way to specify some kind of post-delete code? 回答1: Final

Adding virtual columns to current table in Doctrine?

三世轮回 提交于 2019-12-06 01:27:08
问题 I'm using Doctrine 1.2 with Symfony 1.4. Let's say I have a User model, which has one Profile. These are defined as: User: id username password created_at updated_at Profile: id user_id first_name last_name address city postal_code I would normally get data like this: $query = Doctrine_Query::create() ->select('u.id, u.username, p.first_name, p.last_name') ->from('User u') ->leftJoin('Profile p') ->where('u.username = ?', $username); $result = $query->fetchOne(array(), Doctrine_Core::HYDRATE

Ignore duplicates when using INSERT in a Database with Symfony and Doctrine

余生颓废 提交于 2019-12-06 00:12:54
问题 I have a table CREATE TABLE `sob_tags_articles` ( `tag_id` int(11) NOT NULL, `article_id` int(11) NOT NULL, `id` int(11) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=MyISAM AUTO_INCREMENT=112 And triing to save an object with Doctrine: $sbTagsArticles = new SobTagsArticles(); $sbTagsArticles->article_id = $pubId; $sbTagsArticles->tag_id = $tagId; $sbTagsArticles->save(); But if record exists with the same $pubId and $tagId new record will be insertet with new PK. How to do INSERT

jQuery is not defined (in [Symfony] templating environment)

元气小坏坏 提交于 2019-12-05 23:59:35
I am trying to display a page that uses jQuery. The AJAX functionality implemented in the page does not work. I am using FF for debugging. When I look in the console panel, I see the following error: 'jQuery is not defined'. Ah, that's an easy one I think - maybe the jQuery file has not been included correctly, or not found etc. So I take a look at the HTML and click on the node - lo and behold, the jQuery script has been CORRECTLY included in the page. Although none of the other js libraries in the pages where jQuery is referenced uses '$' (like prototype), I have invoked the noConflict()

What framework(s) would you suggest for a strong, extensible dev platform? [closed]

*爱你&永不变心* 提交于 2019-12-05 23:39:36
问题 Closed . This question is opinion-based. It is not currently accepting answers. Want to improve this question? Update the question so it can be answered with facts and citations by editing this post. Closed 5 years ago . First, let me apologize for Yet Another Framework Question. But I think this is different enough from the usual "What framework should I choose?" to warrant it. Here's my situation: For the past year I've been using a custom framework. It's been used on everything from small

Symfony sfDoctrineGuardPlugin custom login query

青春壹個敷衍的年華 提交于 2019-12-05 20:54:06
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? I think I found a better solution. sfDoctrineGuard plugin has its own post validator that checks for an optional callable for user retrival. //app.yml all: sf_guard_plugin: retrieve_by_username

Extending sfDoctrineRecord in symfony

五迷三道 提交于 2019-12-05 20:23:25
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 "right" way to do that? (P.S. When I say "instance class", I mean something like lib/model/doctrine