Search Results

Search found 6564 results on 263 pages for 'symfony forms'.

Page 35/263 | < Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >

  • Using Propel ORM in my own custom classes

    - by Stick it to THE MAN
    I am refactoring a few classes I wrote a while ago, into my Symfony project (v1.3.2 with Propel ORM). The classes originally used direct connections to the database, I want to refactor those classes (stored in $(SF_LIB_DIR)) so that I can call propel and also use the ORM objects. To clarify, So for example, I want to be able to use code like this in my custom classes: try { $con = Propel::getConnection(); $c = new Criteria(); $foo = new PropelORMFooObject(); $foobar = PropelORMFooBarObjectPeer::fetch($c); //set fields etc $foo->setFooBar($foobar); // now save using obtained connection .. $foo->save($con) }catch(SomeException $e) { //deal with it } I assume that I will need to add some require_once() statements to my custom libraries, but it is not clear which files to include. Does anyone know how to do this?

    Read the article

  • Symfony2 Include in html in Twig

    - by Haritz
    I am developing an application usin Symfony2 and twig for templates. I am using a 3 level structure for templates. Base.html.twig, layout.html.twig and childtemplate.html.twig. The problem is I am trying to include one example.html (common html file) in the next child template by using include but it doesnt work properly. Where can the problem be? {# src/Anotatzailea/AnotatzaileaBundle/Resources/views/Page/testuaanotatu.html.twig #} {% extends 'AnotatzaileaAnotatzaileaBundle::layout.html.twig' %} {% block title %}Testua anotatu{% endblock%} {% block body %} {% include "var/www/Symfony/web/example.html" %} {% endblock %}

    Read the article

  • Django: Prefill a ManytoManyField

    - by Emile Petrone
    I have a ManyToManyField on a settings page that isn't rendering. The data was filled when the user registered, and I am trying to prefill that data when the user tries to change it. Thanks in advance for the help! The HTML: {{form.types.label}} {% if add %} {{form.types}} {% else %} {% for type in form.types.all %} {{type.description}} {% endfor %} {% endif %} The View: @csrf_protect @login_required def edit_host(request, host_id, template_name="host/newhost.html"): host = get_object_or_404(Host, id=host_id) if request.user != host.user: return HttpResponseForbidden() form = HostForm(request.POST) if form.is_valid(): if request.method == 'POST': if form.cleaned_data.get('about') is not None: host.about = form.cleaned_data.get('about') if form.cleaned_data.get('types') is not None: host.types = form.cleaned_data.get('types') host.save() form.save_m2m() return HttpResponseRedirect('/users/%d/' % host.user.id) else: form = HostForm(initial={ "about":host.about, "types":host.types, }) data = { "host":host, "form":form } return render_to_response(template_name, data, context_instance=RequestContext(request)) Form: class HostForm(forms.ModelForm): class Meta: model = Host fields = ('types', 'about', ) types = forms.ModelMultipleChoiceField( widget=forms.CheckboxSelectMultiple, queryset=Type.objects.all(), required=True) about = forms.CharField( widget=forms.Textarea(), required=True) def __init__(self, *args, **kwargs): super(HostForm, self).__init__(*args, **kwargs) self.fields['about'].widget.attrs = { 'placeholder':'Hello!'}

    Read the article

  • Multi choice form field in Django

    - by Dingo
    Hi! I'am developing application on app-engine-path. I would like to make form with multichoice (acceptably languages for user). Code look like this: Language settings: settings.LANGUAGES = ((u"cs", u"Ceština"), (u"en", u"English")) Form model: class UserForm(forms.ModelForm): first_name = forms.CharField(max_length=100) last_name = forms.CharField(max_length=100) languages = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=settings.LANGUAGES) The form is rendered o.k. (all languages have checkbox. IDs, NAMEs is ok.) But if I save some languages for user, those languages don't check checkboxes. User model look like this class User(User): #... languages = db.StringListProperty() #... and view: def edit_profile(request): user = request.user if request.method == 'POST': form = UserForm(request.POST) if form.is_valid(): # ... else: form = UserForm(instance=user) data = {"user":user, "form": form} return render_to_response(request, 'user_profile/user_profile.html', data)

    Read the article

  • Django, ModelForms, User and UserProfile - not hashing password

    - by IvanBernat
    I'm trying to setup a User - UserProfile relationship, display the form and save the data. When submitted, the data is saved, except the password field doesn't get hashed. Additionally, how can I remove the help_text from the username and password (inherited from the User model)? Full code is below, excuse me if it's too long. Models.py USER_IS_CHOICES = ( ('u', 'Choice A'), ('p', 'Choice B'), ('n', 'Ninja'), ) class UserProfile(models.Model): user = models.ForeignKey(User, unique=True) user_is = models.CharField(max_length=1, choices=USER_IS_CHOICES) Forms.py class UserForm(forms.ModelForm): class Meta: model = User fields = ["first_name", "last_name", "username", "email", "password"] def clean_username(self): username = self.cleaned_data['username'] if not re.search(r'^\w+$', username): raise forms.ValidationError('Username can contain only alphanumeric characters') try: User.objects.get(username=username) except ObjectDoesNotExist: return username raise forms.ValidationError('Username is already taken') class UserProfileForm(forms.ModelForm): class Meta: model = UserProfile fields = ['user_is'] Views.py if request.method == 'POST': uform = UserForm(request.POST) pform = UserProfileForm(request.POST) if uform.is_valid() and pform.is_valid(): user = uform.save() profile = pform.save(commit = False) profile.user = user profile.save() return HttpResponseRedirect('/') else: uform = UserForm() pform = UserProfileForm() variables = RequestContext(request, { 'uform':uform, 'pform':pform }) return render_to_response('registration/register.html', variables)

    Read the article

  • Preventing Doctrine from Dropping / Recreating Database When using build --all

    - by Levi Hackwith
    The problem: I have a database that's running on a shared server. I do not have permission to drop/ create a database via the command line doctrine SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'opnsrce'@'173.236.128.0/255.255.128.0' to database 'dev'. Failing Query: "DROP DATABASE dev" doctrine Creating "all" environment "doctrine" database doctrine SQLSTATE[42000]: Syntax error or access violation: 1044 Access denied for user 'opnsrce'@'173.236.128.0/255.255.128.0' to database 'dev'. Failing Query: "CREATE DATABASE dev" This error occurs when I run /dh/cgi-system/php5.cgi symfony doctrine:build --all --no-confirmation The Question: How do I run build-all while simultaneously telling doctrine to not drop / create the database (it already exists)?

    Read the article

  • Are Symphony and CakePHP too slow to be usable?

    - by Aziz Light
    Until now, I have always said that CakePHP is too bloated and slow. I don't really know that, I just saw "some" benchmarks. What I really want to know, is that if those two frameworks (Symfony and CakePHP) are too slow to be usable in a way that the user will get frustrated. I already know that those frameworks are slower than other alternatives, but that's not the question. I ask the question because I want to create a project management web application and I still hesitate between a couple frameworks. I've had some trouble learning Zend, but imho I haven't tried hard enough. So in conclusion, in addition to the first question above, I would like to ask another question: If I want to create a project management tool (which is a pretty big project), which of the following should you suggest, considering the developement time, the speed of the resulting application, and the robustness of the final product: Symphony CakePHP Zend Framework Also I should mention that I don't know any of those frameworks, and that I want to learn one of them (at least).

    Read the article

  • doctrine2: many-to-one with non default referencedColumnName does not persist entity

    - by timaschew
    I'm using symfony 2.1.2 with FOSUserBundle. I extend the User from FOS and define a many-to-one (bidirectional) association to a Customer entity. I don't want to use primary key for the association (referencedColumnName). I will use another integer uniqe column: customer_no use FOS\UserBundle\Entity\User as BaseUser; /** * @ORM\Entity * @ORM\Table(name="t_myuser") */ class MyUser extends BaseUser { /** * @ORM\ManyToOne(targetEntity="Customer", inversedBy="user") * @ORM\JoinColumn(name="customer_no", referencedColumnName="customer_no", nullable=false) */ $public $customer; } /** * @ORM\Entity * @ORM\Table(name="t_customer") */ class Customer extends BaseEntity // provides an id (pk) { /** * @ORM\Column(type="integer", unique=true, nullable=false) */ public $customer_no; /** * @ORM\OneToMany(targetEntity="MyUser", mappedBy="customer") */ public $user; } When I try to persist (via a form) a new MyUser entity with an (already in db existing and) loaded Customer entity from db, I get this error: Notice: Undefined index: customer_no in ...\vendor\doctrine\orm\lib\Doctrine\ORM\Persisters\BasicEntityPersister.php line 608 The schema on the db is all right. //update: I fix the inversedBy and mappedBy stuff, but this is not the problem.

    Read the article

  • How to diganose an unlogged Error 500 on Apache?

    - by samuel morhaim
    We are running a very simple Symfony script, that randomly returns an Error 500. The system administrator says he can't find any trace of an Error 500 on the error logs, however using Curl or Firebug, it is obvious that an Error 500 is being returned. The script simply parses a POST request submitted to an URL on our server. We already checked for performance, memory etc but nothing seems to be the problem. How is this possible? We already enabled all debugging, logging, on Apache, PHP, etc and nothing.

    Read the article

  • Sign Up/Login system for multi-domain/multi-server

    - by David
    I'm thinking about a good solution for implementing a sign up/login system that works across different domains and servers. A working example is Olx (you can register in one domain, and your login will work in the rest of domains). The scenario is that every domain (one per country) has its own database. And there will be 2 servers (for example), each one will have the 50% of the domains (and so the 50% of databases). What would you suggest to start with? Database: MySQL 5.1 Server-side language: PHP 5.3 (I will be using Symfony 1.4, so if someone has some suggestion for this framework, it will be interesting too, although it is optional)

    Read the article

  • One to two relationship in Doctrine with YAML

    - by Jeremy DeGroot
    I'm working on my first Symfony project with Doctrine, and I've run into a hitch. I'm trying to express a game with two players. The relationship I want to have is PlayerOne and PlayerTwo each being keyed to an ID in the Users table. This is part of what I've got so far: Game: actAs: { Timestampable:- } columns: id: { type: integer, notnull: true, unique: true } startDate: { type: timestamp, notnull: true } playerOne: { type: integer, notnull: true } playerTwo: { type: integer, notnull: true } winner: { type: integer, notnull:true, default:0 } relations: User: { onUpdate: cascade, local: playerOne, foreign: id} User: { onUpdate: cascade, local: playerTwo, foreign: id} That doesn't work. It builds fine, but the SQL it generates only includes a constraint for playerTwo. I've tried a few other things: User: { onUpdate: cascade, local: [playerOne, playerTwo], foreign: id} Also: User: [{ onUpdate: cascade, local: playerOne, foreign: id}, { onUpdate: cascade, local: playerTwo, foreign: id}] Those last two throw errors when I try to build. Is there anyone out there who understands what I'm trying to do and can help me achieve it?

    Read the article

  • Outputting an HTML entity character from a helper function

    - by morpheous
    I am using Symfony 1.3.2 on Ubuntu. I have written a little helper function (statsfoo) that prints out summary statistics about an item. I am using the helper function in my template like this: // In StatsHelper.php <?php function statsfoo($some_param) { return "<div class=\"sfoo\">&9830; the stats number for item is 42</div>" } //In showStatsSuccess.php <?php use_helper(Stats); <?php echo statsfoo($foobar, ESC_ENTITIES); I tried both ESC_ENTITIES and ESC_RAW. In both instances, the raw number (&9830) was displayed in the page. I want to display the diamond instead. What am I doing wrong and how can I fix this?

    Read the article

  • Symfony2 Syntax Errors (in vendor files)

    - by user1665246
    To maintain code integrity across our servers we'd like to keep the /vendor/* directory under source control, rather than use composer to download files each time we roll out onto another server - i.e. we can be certain that the /vendor/* files are identical. We run a syntax checker against all files committed to source control and run across the following error: File '/vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle/Bundle.php' failed the PHP syntax check with the following error: PHP Parse error: syntax error, unexpected '}', expecting T_NS_SEPARATOR in /vendor/sensio/generator-bundle/Sensio/Bundle/GeneratorBundle/Resources/skeleton/bundle/Bundle.php on line 3 Is the "error" in this file intentional ? Any help appreciated. File contents below: <?php namespace {{ namespace }}; use Symfony\Component\HttpKernel\Bundle\Bundle; class {{ bundle }} extends Bundle { }

    Read the article

  • Easy to use/learn PHP framework?

    - by Meredith
    I need to build a php app, and I was thinking about using a framework (never used one before). I've been browsing around some but most of them seems kinda complicated, I really liked what I saw about Symfony, but it looks like I will have to spend like a month until I really understand how to use it, and in one month I could code the app I have in mind 5 times without a framework. But I want to use one to "standardize" my code and prevent bugs. So I was wondering if someone could share with me which php frameworks you think are easier to learn how to use. My application will use mysql, and it will have some sort of "search engine" to search data that will be populated on the database using a few "scraper scripts" (that I also wants to code using the framework).

    Read the article

  • clean method for validation

    - by apoorva
    hi.. i have the following form class with corresponding clean methods... class SOFIATMUserLogin(forms.Form): Username=forms.CharField(label='Username') Password=forms.CharField(label='Password', widget=forms.PasswordInput) def clean_Username(self): user=self.cleaned_data['Username'] try: SOFIALogin.objects.get(UserName=user) except Exception: raise forms.ValidationError('Username invalid...') def clean_Password(self): upass=self.cleaned_data['Password'] In the clean_Password method i wish to check if the password entered for the valid username is correct... So i need to get the Username value... How can i access this in clean_Password method... Please assist!!!!

    Read the article

  • django form ModelChoiceField loads all state names while needed states which are mapped with current selected country

    - by Sonu
    I am using modelChoiceField to display country and state into address form class StateSelectionwidget(forms.Select): """ custom widget to state selection""" class Media: js = ('media/javascript/public/jquery-1.5.2.min.js', 'media/javascript/public/countrystateselection.js', ) class AddressForm(forms.Form): name = forms.CharField(max_length=30) country = forms.ModelChoiceField(queryset=[]) state = forms.ModelChoiceField(CountryState.objects, widget=StateSelectionwidget) def __init__(self, *args, **kwargs): super(AddressForm, self).__init__(*args, **kwargs) self.fields['country'].queryset = Country.objects.all() Country model is used to store country names. CountryState model is used to store all states which is foreign key to Country model At the time of form loading i am getting all state names in dropdown while i want field to be blank by default. If name field is empty at the time of form save i am getting error that name can not be empty but also getting all states into dropdown list while i want only the states which are mapped with current selected country.

    Read the article

  • sfConfig::get is not returning constants defined in app.yml

    - by morpheous
    I have an interesting problem. I am using Symfony 1.3.2. I have defined some constants in project/apps/frontend/config/app.yml and project/config/app.yml When I use the constant (correct spelling) in a piece of code like this $test=sfConfig::get('app_foobar'); the variable $test is assigned a null value. This is what I have checked so far: CHECK: cache files generated? (YES) CHECK: Do the cache files (config_app.yml.php) in the cache directory contain the constants defined in the app.yml file (YES) CHECK: Constant names used in the code matches the array keys found in config_app.yml? (YES) At this stage, I have run out of ideas. I dont want to supply a default value as a hack, because when I need to change the value of the constant, I will have to replace this in potentially hundreds of instances (too error prone). Is there anything that I have missed?. What could be causing this?

    Read the article

  • How to make form validation in Django dynamic?

    - by Oli
    I'm trying to make a form that handles the checking of a domain: the form should fail based on a variable that was set earlier in another form. Basically, when a user wants to create a new domain, this form should fail if the entered domain exists. When a user wants to move a domain, this form should fail if the entered domain doesn't exist. I've tried making it dynamic overload the initbut couldn't see a way to get my passed variabele to the clean function. I've read that this dynamic validation can be accomplished using a factory method, but maybe someone can help me on my way with this? Here's a simplified version of the form so far: #OrderFormStep1 presents the user with a choice: create or move domain class OrderFormStep2(forms.Form): domain = forms.CharField() extension = forms.CharField() def clean(self): cleaned_data = self.cleaned_data domain = cleaned_data.get("domain") extension = cleaned_data.get("extension") if domain and extension: code = whoislookup(domain+extension); #Raise error based on result from OrderFormStep1 #raise forms.ValidationError('error, domain already exists') #raise forms.ValidationError('error, domain does not exist') return cleaned_data

    Read the article

  • Base form controls not visible in child form

    - by Kildareflare
    Hello I'm using C#.Net and have a base form that is inherited by several forms. Until yesterday, when the child (derived) form was opened in the designer the base forms controls would be displayed and shown as locked. Now, however the form is simply blank. None of the base forms controls are visible in the designer. Everything compiles, builds and runs OK. Has anyone else seen this? I've tried placing a call to the base forms InitializeComponent method in the derived forms OnLoad method but to no avail.

    Read the article

  • How should flushing be handled in a doctrine EntityManager instance shared across different services in symfony2?

    - by Jbm
    I have defined several services in symfony 2 which persist changes to the database. These services have the doctrine instance as one of their dependencies: a.given.service: class: Acme\TestBundle\Service\AGivenService arguments: [@doctrine] If I have two different services and both of them persist objects through the EntityManager, which is obtained like this from the doctrine instance: $em = $doctrine->getEntityManager(); Would all services always share the same EntityManager? If so, how should I handle flushing if I wanted to handle all the changes in a single transaction? I have checked this: http://docs.doctrine-project.org/projects/doctrine-orm/en/2.0.x/reference/transactions-and-concurrency.html and it explains how to handle different transactions in a request, but I want to achieve the opposite, which is having different changes in different services handled as a single transaction. Is there a better approach to handle multiple changes in different services? For now my best bet is having a front-end service in charge of calling the other services and doing the flushing afterwards. Backend services would persist objects but would not do any flushing.

    Read the article

  • What is the most efficient approach to fetch category tree, products, brands, counts by subcategory

    - by alex227
    Symfony 1.4 + Doctrine 1.2. What is the best way to minimize the number of queries to retrieve products, subcategories of current category, product counts by subcategory and brand for the result set of the query below? Categories are a nested set. Here is my query: $q = Doctrine_Query::create() ->select('c.*, p.product,p.price, b.brand') ->from('Category c') ->leftJoin('c.Product p') ->leftJoin('p.Brand b') ->where ('c.root_id = ?', $this->category->getRootId()) ->andWhere('c.lft >= ?', $this->category->getLft()) ->andWhere('c.rgt <= ?', $this->category->getRgt()) ->setHydrationMode(Doctrine_Core::HYDRATE_ARRAY); $treeObject = Doctrine::getTable('Category')->getTree(); $treeObject->setBaseQuery($q); $this->treeObject = $treeObject; $treeObject->resetBaseQuery(); $this->products = $q->execute();

    Read the article

  • Password Hash Implementation

    - by oyerli
    I am developing a new application using Symfony. I want to store the passwords hashed, so I overridded the save method in my User model: public function save(Doctrine_Connection $conn = null) { $this->setUserPassword( md5($this->getUserPassword()) ); return parent::save($conn); } This works good when a new user created. However, this causes problems when we edit a user without changing his password. This causes Doctrine to hash the already hashed password. So, I need to check that whether the UserPassword is modified in this DoctrineRecord instance. How can I manage to do that?

    Read the article

  • database structure for threads that are editable by many users?

    - by fayer
    at the moment i have a column "user_id" in the "threads" table cause one thread belongs to an user. i want to make it like Stackoverflow that one thread can be editable by many users and you can see when they edited, what they edited, roll back changes and so on. im using symfony, is there a plugin for this? if no, are there any 3rd part libraries/plugins to download for this to integrate to existing database? cause i have no idea how to implement this. it sounds like mediawiki, something that already exists? thanks

    Read the article

  • PHP : Symfony sort en version 2.1 définitive, gestion des dépendances avec Composer, formulaires plus efficaces et Mailer plus performant

    Symfony2 est un projet très communautaire, depuis le début (des centaines de bundles étaient disponibles bien avant les premières RC de la 2.0), une tendance qui se confirme : 250 contributeurs, 1 000 pull requests sur GitHub pour la première version beta de Symfony 2.1 ! Après les difficultés de migration avec symfony 1.x, l'équipe a tenté autant que possible de restreindre les changements à même de casser la rétrocompatibilité ; de même, le refactoring du module de formulaires a fait que la version finale de la 2.1 devrait sortir en août, afin de concentrer autant que possible les changements et faire que de plus en plus de code ne devra pas être modifié lors de la migration d'une version à l'autre. Ainsi, n'hésitez pas à tenter de migrer vos applications vers cette beta,...

    Read the article

  • PHP : Symfony sort en version 2.1 définitive, gestion des dépendances avec Composer, formulaires et Mailer plus performants

    Symfony2 est un projet très communautaire, depuis le début (des centaines de bundles étaient disponibles bien avant les premières RC de la 2.0), une tendance qui se confirme : 250 contributeurs, 1 000 pull requests sur GitHub pour la première version beta de Symfony 2.1 ! Après les difficultés de migration avec symfony 1.x, l'équipe a tenté autant que possible de restreindre les changements à même de casser la rétrocompatibilité ; de même, le refactoring du module de formulaires a fait que la version finale de la 2.1 devrait sortir en août, afin de concentrer autant que possible les changements et faire que de plus en plus de code ne devra pas être modifié lors de la migration d'une version à l'autre. Ainsi, n'hésitez pas à tenter de migrer vos applications vers cette beta,...

    Read the article

< Previous Page | 31 32 33 34 35 36 37 38 39 40 41 42  | Next Page >