GithubHelp home page GithubHelp logo

propelorm / sfpropelormplugin Goto Github PK

View Code? Open in Web Editor NEW
109.0 19.0 95.0 650 KB

symfony 1.x plugin for Propel.

Home Page: http://www.propelorm.org/

License: Other

PHP 98.56% Shell 0.11% CSS 1.16% Hack 0.17%

sfpropelormplugin's Introduction

sfPropelORMPlugin

Build Status

Replaces symfony's core Propel plugin by the latest version of Propel, in branch 1.6.

Installation

The Composer way

Add the require to your composer.json. It's oddly named but like this Composer's symfony1 installer camelcases it correctly. Composer will install it into your project's plugins directory automatically, and add the requirements.

{
    "config": {
        "vendor-dir": "lib/vendor"
    },
    "require": {
        "propel/sf-propel-o-r-m-plugin": "dev-master"
    }
}

Of course, don't forget to add Composer's autoloader to your ProjectConfiguration:

// config/ProjectConfiguration.class.php

require __DIR__ .'/../lib/vendor/autoload.php';

require_once dirname(__FILE__) .'/../lib/vendor/symfony/lib/autoload/sfCoreAutoload.class.php';
sfCoreAutoload::register();

class ProjectConfiguration extends sfProjectConfiguration
{
    public function setup()
    {
        $this->enablePlugins(array(
            'sfPropelORMPlugin',
            ...
        ));

        // mandatory because of the Composer vendor directory naming scheme
        sfConfig::set('sf_phing_path', sfConfig::get('sf_lib_dir') .'/vendor/phing/phing');
        sfConfig::set('sf_propel_path', sfConfig::get('sf_lib_dir') .'/vendor/propel/propel1');
    }
}

The Git way

Clone the plugin from Github:

git clone https://github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin
cd plugins/sfPropelORMPlugin
git submodule update --init

If you use Git as a VCS for your project, it should be better to add the plugin as a submodule:

git submodule add https://github.com/propelorm/sfPropelORMPlugin.git plugins/sfPropelORMPlugin
git submodule update --init --recursive

As both Phing and Propel libraries are bundled with the plugin, you have to initialize submodules for the plugin.

The SVN way

Install the plugin via the subversion repository:

svn checkout https://github.com/propelorm/sfPropelORMPlugin/trunk plugins/sfPropelORMPlugin

Install Phing and Propel:

svn checkout http://phing.mirror.svn.symfony-project.com/tags/2.3.3/classes/phing lib/vendor/phing
svn checkout https://github.com/propelorm/Propel/tags/1.6.5 lib/vendor/propel

Final step

Disable the core Propel plugin and enable the sfPropelORMPlugin instead. Also, change the location for the Propel and Phing libs.

// config/ProjectConfiguration.class.php

class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    //setup the location for our phing and propel libs
    sfConfig::set('sf_phing_path', sfConfig::get('sf_root_dir').'/plugins/sfPropelORMPlugin/lib/vendor/phing/');
    sfConfig::set('sf_propel_path', sfConfig::get('sf_root_dir').'/plugins/sfPropelORMPlugin/lib/vendor/propel/');
    sfConfig::set('sf_propel_generator_path', sfConfig::get('sf_root_dir').'/plugins/sfPropelORMPlugin/lib/vendor/propel/generator/lib/');

    $this->enablePlugins('sfPropelORMPlugin');
  }
}

Optional: update references to the propel and phing folders in the test project.

// plugins/sfPropelORMPlugin/test/functional/fixtures/config/ProjectConfiguration.class.php

class ProjectConfiguration extends sfProjectConfiguration
{
  public function setup()
  {
    $this->enablePlugins(array('sfPropelORMPlugin'));
    $this->setPluginPath('sfPropelORMPlugin', realpath(dirname(__FILE__) . '/../../../..'));

    // SVN way
    //sfConfig::set('sf_propel_path', SF_DIR.'/../lib/vendor/propel');
    //sfConfig::set('sf_phing_path', SF_DIR.'/../lib/vendor/phing');

    // Git way
    sfConfig::set('sf_propel_path', realpath(dirname(__FILE__) . '/../../../../lib/vendor/propel'));
    sfConfig::set('sf_phing_path', realpath(dirname(__FILE__) . '/../../../../lib/vendor/phing'));
  }

Right after the installation of the plugin, you should update plugin assets:

php symfony plugin:publish-assets

Change the path of the symfony behaviors in the config/propel.ini file of your project:

// config/propel.ini

propel.behavior.symfony.class                  = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfony
propel.behavior.symfony_i18n.class             = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18n
propel.behavior.symfony_i18n_translation.class = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorI18nTranslation
propel.behavior.symfony_behaviors.class        = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorSymfonyBehaviors
propel.behavior.symfony_timestampable.class    = plugins.sfPropelORMPlugin.lib.behavior.SfPropelBehaviorTimestampable

(Re)Build the model:

php symfony propel:build --all-classes

What's New In Propel 1.6

Propel 1.6 is a backwards compatible evolution of Propel 1.4 (the version bundled with symfony 1.3 and 1.4), which adds some very interesting features. Among these features, you will find the new Propel Query API, which is essentially a Criteria on steroids:

// find the 10 latest books published by authror 'Leo'
$books = BookQuery::create()
    ->useAuthorQuery()
    ->filterByFirstName('Leo')
    ->endUse()
    ->orderByPublishedAt('desc')
    ->limit(10)
    ->find($con);

Propel 1.6 also supports many-to-many relationships, collections, on-demand hydration, new core behaviors (see below), better Oracle support, and is now licensed under the MIT license.

Core Propel Behaviors

Propel 1.6 bundles most common behaviors in a new, robust buildtime implementation. These core behaviors provide faster runtime execution and the ability to modify the data model:

sfPropelORMPlugin allows you to register core propel behaviors right from your schema.yml. For instance, to create a tree structure from a Section model:

propel:
    section:
    _attributes: { phpName: Section }
    _propel_behaviors:
        - nested_set
    id: ~
    title: { type: varchar(100), required: true primaryString: true }

Tip: Check the doc/schema.md file in this plugin source code for a complete reference of the YAML schema format.

You can also register a behavior for all your models right in the propel.ini configuration file. sfPropelORMPlugin already enables the symfony and symfony_i18n behaviors to support symfony's behavior system and model localization features, but you can easily add your owns:

propel.behavior.default = symfony,symfony_i18n,alternative_coding_standards,auto_add_pk

Admin Generator Extensions

The plugin comes bundled with a new admin generator theme named 'admin15'. This theme is backwards compatible with sfPropelPlugin's admin generator theme, and provides additional features based on the new Propel 1.6 query objects:

List view enhancements

  • Easy related objects hydration: You don't need to write custom doSelectJoinXXX() methods to hydrate related objects. The with setting is much more poxwerful that the previous peer_method and peer_count_method settings, and much easier to use.
  • Custom query methods: You can refine the query executed to display the list view by by setting the query_methods parameter. This allows to hydrate an additional column wit hno additional query, or to pre-filter the list to hide rows that the user shouldn't see.
  • All columns are sortable: Virtual columns and foreign key columns are now sortable in the list view. You'll need to set the sort method to use for that, but it's a one-liner. No more lists with column headers that can't be clicked for sorting!
  • Easy links to filtered lists: A link to a fitlered list view is very easy to write with the new theme. Just add GET parameter, the same way you used to do with the admin generator in symfony 1.2, and it works
  • Links to another admin module: To make a foreign key column link to the edit view of the related object in another module, you no longer need to create a partial. Just define the link_module setting in the foreign key field configuration, and you're good to go:
  • Easy custom filters: Adding custom filters becomes very easy once you can take advantage of the generated Propel query classes. This allows your, for instance, to setup a full-text search input in two minutes, replacing many text filters by a single one for better usability.
  • Automatic sortable links: If a module is generated on a model with sortable behavior, actions for moving records up and down are automatically added.

Filter and Edit forms enhancement

  • YAML widget customization: The generator.yml format was extended to allow widget and validator customization directly in YAML, without the need to edit a form object. You can also safely omit a field from a display list in a form definition, without any risk to loose data.
  • Plain text field: If you want to display some data in a form without allowing the user to edit it, use the type: plain attribute, just like in the old days of symfony 1.2. This is very useful for columns managed by the model, like created_at and updated_at columns.

The new options for the admin15 generator theme are fully documented, and illustrated by real life examples, in the doc/admin_generator.md file in this plugin source code.

Form Subframework Modifications

  • Updated sfWidgetFormPropelChoice widget: The widget now uses the new Query API. You can customize the list of choices more easily by executing custom query methods, using the new query_methods option.
  • Updated Propel validators: Both the sfValidatorPropelChoice and the sfValidatorPropelUnique were updated to use the new PropelQuery objects, and to accept a query_methods option similar to the one of sfWidgetFormPropelChoice.
  • Plain text widget and validator: This new widget allows a field to be displayed in a form, without letting the use change it.
  • Easy Relation Embed: Editing related objects together with the main objects (e.g., editing Comments in a Post form) is a piece of cake. The new sfFormPropel::embedRelation() method does all the work to fetch related objects, build the forms for each of them, and embed the related object forms into the main form. Embdeded relation forms allow to edit, add, and delete a related objects with no additional code.
class ArticleForm extends BaseArticleForm
{
  public function configure()
  {
    $this->embedRelation('Book');
  }
}

The Propel widgets, validators, and form classes are fully documented in the doc/form.md file in this plugin source code.

Filter Subframework modification

You now can merge or embed filters into filters, it works out of the box.

class ArticleFilter extends BaseArticleFilter
{
  public function configure()
  {
    $this->mergeForm(new AuthorFilter());
  }
}

Routing Modifications

The plugin offer two new routing classes, sfPropelORMRoute and sfPropelORMRouteCollection. These classes are used by default in the models build with the propel admin generator. They behave just like the previous sfPropelRoute class - except they don't use the methods option anymore. Instead, use the query_methods option to execute a list of arbitrary query methods when calling getObject() and getObjects().

author:
    class: sfPropelORMRouteCollection
    options:
    model:                author
    module:               author
    prefix_path:          /author
    column:               id
    query_methods:
        object: [filterByIsPublished]
        list:   [filterByIsPublished, orderByLastName]
    with_wildcard_routes: true

Array of additional parameters are also possible for query_methods:

author:
    class: sfPropelORMRouteCollection
    options:
    model:                author
    module:               author
    prefix_path:          /author
    column:               id
    query_methods:
        object:
        filterByIsPublished: [false]
        list:
        filterByIsPublished: []
        orderBy:             [LastName]
    with_wildcard_routes: true

sfPropelORMRoute also makes your code a little easier to read in the action. Instead of calling getObject(), you can actually call a getter using the class name of the object's route:

public function executeShow(sfWebRequest $request)
{
    // using sfPropelORMRoute with 'Author' as model
    $this->author = $this->getRoute()->getAuthor();
}

A new option has been added to both sfPropelORMRoute and sfPropelORMRouteCollection, the connection option allows to set a specific Propel connection to use. Examples:

author_show:
  url:     /author/:id
  class:   sfPropelORMRoute
  param:   { module: myModule, action: show }
  options: { model: Author, type: object, connection: my_connection }
author:
    class: sfPropelORMRouteCollection
    options:
    model:                Author
    module:               author
    prefix_path:          /author
    column:               id
    connection:           my_connection
    with_wildcard_routes: true

sfpropelormplugin's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sfpropelormplugin's Issues

insert-sql task doesn't insert foreign key constraints when using PostgreSQL with multiple schema files and packages

We discovered a problem when using relations between postgresql tables of different packages in multiple schema files. We're using propel 1.6, php 5.3.2 and postgresql 8.4.7

The SQL files are generated correctly and can be inserted into database by hand without errors. But when using the propel insert-sql task the constraints are not created in database (in our example the relation between tables "ls_image" and "ls_vendor_image").

Below you find 2 example schema files:

001_media_schema.yml

propel:
    ls_image:
        _attributes:  { phpName: lsImage, package: lib.model.media }
        id:
        filename:     { type: varchar, size: 255, required: true, index: unique }
        description:  { type: varchar, size: 5000 }
        author:       { type: varchar, size: 255 }
        created_at:
        updated_at:

002_vendor_schema.yml

propel:
    ls_vendor:
        _attributes:        { phpName: lsVendor, package: lib.model.vendor }
        id:                 { type: bigint, primaryKey: true, required: true, autoIncrement: true }
        name:               { type: varchar, size: 255, required: true }
        is_active:          { type: boolean, default: true, required: true }

    ls_vendor_image:
        _attributes:        { phpName: lsVendorImage, package: lib.model.vendor }
        id:
        vendor_id:          { type: bigint, required: true, foreignTable: ls_vendor, foreignReference: id, onDelete: cascade }
        image_id:           { type: integer, required: true, foreignTable: ls_image, foreignReference: id, onDelete: cascade }
        name:               { type: varchar, size: 255, required: true }

database connection encoding doesn't work anymore

I have just upgraded from sfPropel15Plugin to sfPropelORMPlugin, and now the database connection isn't set to utf8 anymore.
Like always I have all: propel: param: encoding: utf8 in my databases.yml.

Using MySQL btw.

Separate vendor libs from the plugin

Hi there,

For now, this plugin works very fine with Git but it's still a pain with SVN. As you may know you have to add third-party libs to lib/vendor in the plugin itself. It leads to an error as SVN through Github create these directories:

  • plugins/sfPropelORMPlugin/lib/vendor
  • plugins/sfPropelORMPlugin/lib/vendor/phing
  • plugins/sfPropelORMPlugin/lib/vendor/propel

With in each a .svn/ directory. That's why you cannot checkout an SVN repo in these directories nor to create SVN externals...
The major problem is that these libs are couplate to the plugin as some require are using relative paths..

We have to use the two following parameters:

  • sf_propel_path
  • sf_phing_path

By default, these two parameters will reference plugins/sfPropelORMPlugin/lib/vendor/propel and plugins/sfPropelORMPlugin/lib/vendor/phing.
If we are able to deal with these two parameters in the whole plugin, SVN users will be able to checkout/create externals in lib/vendor/ which is the default lib directory of a symfony 1.x project.

Any suggestions ? Can someone work on a patch for that ? It's not really hard, we just need to check all files which uses require or include functions with a relative path...

Regards,
William

Migration tasks assumes that all database connections should be handled

Hi

I'm using 1.6 branch together with symfony 1.4, MySQL 5.1

In my project I have three different connections defined in databases.yml file.
Migration up/down (and maybe others) tasks tries to create propel_migration table in all defined connections/databases and this causes exception.

In my case due to security concerns mysql users that are defined inside databases.yml does not have CREATE privilege.

As I see there is no way to tell migration related tasks to act on just one concrete connection which could solve my problem.

Is there a chance for some solution to that problem ?

best regards
Lukasz

php fatal error in propel:diff when there are no changes to the DB

If propel:diff is run when no changes have been introduced to the schema, the following error is generated:

Fatal error: Call to a member function getDescription() on a non-object in [snip]\plugins\sfPropel15Plugin\lib\task\sfPropelDiffTask.class.php on line 145

SQL Error in the output from the generator.

Hey Guys,

I found, what appears to be, a small bug with the generator (as of commit bd5de50 in sfPropelORMPlugin). When I create a table that has a foreign key to itself (as in a tree structure), it adds an extra index with no name.

INDEX `I_referenced_gst_user_FK_2_1` (``),

When I change the schema.xml to point to a different table, the bug disappears and everything is fine. But naming a foreign key to the same table, results in this added (and apparently unnecessary) index. Removing the index SQL fixes the error as well.

Thanks a bunch for making Propel! I've been using it for 4 years and I still think it's the best PHP ORM out there. Cheers.

Embedded i18n form in an embedded relation creates 2 records

Symfony 1.4
Propel (with sfPropel15Plugin)

I have a multilanguage Gallery with the following schema:

# Galleries

  pi_gallery:
    _attributes:
      phpName: Gallery
      isI18N: true
      i18nTable: pi_gallery_i18n
    _propel_behaviors:
      sortable: ~
    id: ~
    active:
      type: boolean
      default: true
      required: true
    created_at: ~
    updated_at: ~        

  pi_gallery_i18n:
    _attributes:
      phpName: GalleryI18n
    id: 
      type: integer
      foreignTable: pi_gallery
      foreignReference: id
      required: true
      primaryKey: true
      onDelete: cascade
    culture:
      isCulture: true
      type: varchar
      size: 7
      required: true
      primaryKey: true
    name:
      type: varchar
      size: 255
      required: false
    description:
      type: longvarchar
      required: false

# Images

  pi_gallery_image:
    _attributes:
      phpName: GalleryImage
      isI18N: true
      i18nTable: pi_gallery_image_i18n
    id: ~
    gallery_id:
      type: integer
      foreignTable: pi_gallery
      foreignReference: id
      required: true
    image:
      type: varchar
      size: 255
      required: true
    created_at: ~
    updated_at: ~


  pi_gallery_image_i18n:
    _attributes:
      phpName: GalleryImageI18n
    id: 
      type: integer
      foreignTable: pi_gallery_image
      foreignReference: id
      required: true
      primaryKey: true
      onDelete: cascade
    culture:
      isCulture: true
      type: varchar
      size: 7
      required: true
      primaryKey: true
    description:
      type: varchar
      size: 255
      required: false

I'm trying to embed the Image forms in the Gallery using the following:

# GalleryForm.class

    public function configure()
    {
        unset(
            $this['alias'],
            $this['created_at'],
            $this['updated_at']
        );

        $this->widgetSchema['article_id']->setOption('renderer_class', 'sfWidgetFormPropelJQueryAutocompleter');
        $this->widgetSchema['article_id']->setOption('renderer_options', array(
                'model'     => 'Article',
                'url'       => '/article/ajax'
        ));

        $this->validatorSchema['article_id'] = new sfValidatorPass();

        $this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));

        $this->widgetSchema->setLabel('en','English');
        $this->widgetSchema->setLabel('es','Español');
        $this->widgetSchema->setLabel('de','Deutsch');
        $this->widgetSchema->setLabel('it','Italiano');
        $this->widgetSchema->setLabel('fr','Francais');

        $this->embedRelation('GalleryImage'); // Embeds the Relation between the GalleryImage model and the Gallery Model
    }


# GalleryImageForm.class:    

    public function configure()
    {        
        unset(
            $this['created_at'],
            $this['updated_at'],
            $this['gallery_id'],
            $this['sortable_rank']
        );

        if ($this->isNew()) unset($this['id']);

        $this->embedI18n(array('es', 'en', 'de', 'it', 'fr'));            

        $image = $this->getObject()->getImage();

        $template = (!is_null($image) || $image != "") ? '<div>%file%<br />%input%<br />%delete% %delete_label%</div>' : '';            

        $this->widgetSchema['image'] = new sfWidgetFormInputFileEditable(array(
            'label' => 'Imagen',
            'file_src' => '/'.sfConfig::get('sf_upload_dir_name').'/images/galleries/thumbs/'.substr($this->getObject()->getImage(),0,-4) . '.jpg',
            'is_image' => true,
            'edit_mode' => !$this->isNew() && $image != "",
            'with_delete' => true,
            'delete_label'=>'Eliminar archivo existente',
            'template' => $template
        ));


        $this->validatorSchema['image_delete'] = new sfValidatorPass();          

        $this->validatorSchema['image'] = new sfValidatorFile(array(
            'path' => sfConfig::get('sf_upload_dir').'/images/galleries',
            'required' => false,
            'mime_types' => 'web_images'
        ));
    }

This appears to embed the forms as expected ... initially. The GalleryForm appears with Multilanguage Descriptions and the ImageForms embed beneath them. So far so good.

Saving the form however shows that all is not good.

Two records are saved initially, one with just the image and the other with just the i18n fields. The i18n fields also have the id of the second record added so there is no way of relating the image to the i18n fields. Maybe the order of saving the forms is wrong?

Has anyone successfully got a form to work that embeds I18n in an embedded Relation? Or does anyone have any idea of a workaround? I've read about something about overriding saveEmbeddedForms but I don't even know where to start with that.

Am posting this here as I have been unable to get any response for more than 2 weeks on any of the other mediums of support.

sfYaml function redeclared

When I was running my unit tests I came across this error:

Fatal error: Cannot redeclare echoln() (previously declared in ...\lib\vendor\symfony\lib\yaml\sfYaml.php:132) in ...\plugins\sfPropel15Plugin\lib\vendor\propel\parser\yaml\sfYaml.php on line 135

I am actually pretty astonished this function is declared outside the class, maybe this should be taken up with the symfony developers?

Unable to execute SELECT statement when using doSelectJoinAll

I'm not sure if this could be a bug or just a specification. Anyway, here's the story.
I have three classes: user, message and user_has_message. In my action I had this (not wrong but bad) code:

$c = new Criteria();
$c->addDescendingOrderByColumn(MessagePeer::UPDATED_AT);
$c->addJoin(UserPeer::ID, UserHasMessagePeer::USER_ID);  //This is the bad coding
$c->add(UserHasMessagePeer::DELETED, 0);
$c->add(UserHasMessagePeer::USER_ID, $this->getUser()->getId());
$c->add(UserHasMessagePeer::READED, 0);
$this->messages = UserHasMessagePeer::doSelectJoinAll($c);

This code gives me an Unable to execute SELECT statement. The resulting SQL is something like this:

SELECT [...] FROM INNER JOIN `user_has_message` ON [...]

As you can see, there's no FROM table! If I remove the $c->addJoin(UserPeer::ID, UserHasMessagePeer::MESSAGE_ID); from my action, everything goes smoothly!
This same code worked with propel 1.5.
I'll investigate but any suggestion (apart from that to write a better code, wich I already know....) will be welcome!

SQL error after updating to propel1.6 beta

Propel 1.5.6: generated SQL is ok

SELECT DISTINCT mateam.ID,.. mabfw.ID_MA, ... FROM mateam CROSS JOIN mabfw_rollen LEFT JOIN mabfw ON (mateam.ID_MA=mabfw.ID_MA)

Propel 1.6.0 - [wrapped: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'mabfw.ID_MA' in 'on clause']

SELECT DISTINCT mateam.ID, ... mabfw.ID_MA, ... FROM mateam INNER JOIN mabfw_rollen ON (mabfw.ID_MA=mabfw_rollen.ID_MA) LEFT JOIN mabfw ON (mateam.ID_MA=mabfw.ID_MA)

Criteria used:
$auswahl->addJoin(MabfwPeer::ID_MA, MabfwRollenPeer::ID_MA);
$auswahl->setDistinct();
$Team->getMateamsJoinMabfw($auswahl)

SfPropelBehaviorTimestampable needs a way to be disabled at runtime

sfPropel15Plugin: SfPropelBehaviorTimestampable needs a way to be disabled at runtime so it can play nice with other behaviors like soft_delete.

Adding keepUpdateDateUnchanged() method from the propel Timestampable behavior would be the best way to accomplish this.

typo in description of propel:insert-sql task

Is: The task connects to the database and executes all SQL statements found in [config/sql/*schema.sql|COMMENT] files.

Should be: The task connects to the database and executes all SQL statements found in [data/sql/*schema.

I18n behavior BaseForm issue

Hi,
I already post this issue, but in reply to a closed ticket that partially resolved my problem and it may have more visibility as a new one which I simplified
https://github.com/fzaninotto/sfPropel15Plugin/issues/closed#issue/15/comment/744365

My schema :
my_table:
_propel_behaviors:
auto_add_pk: ~
i18n:
i18n_columns: [description]
locale_alias: culture
name: {type: varchar(150), index: true}
description: {type: longvarchar}
active: {type: boolean}

Using
./symfony propel:build-all
I get a "Notice" written in the base form for my model.

lib/form/base/BaseMyTableForm.class.php
/**
* MyTable form base class.
*
* @method MyTable getObject() Returns the current form's model object
*
* @subpackage form
* @author Studio Mandinga
*/
abstract class BaseMyTableForm extends BaseFormPropel
{
public function setup()
{
$this->setWidgets(array(
'name' => new sfWidgetFormInputText(),
'id' => new sfWidgetFormInputCheckbox(),
'
Notice: Undefined offset: 3 in /home/my_project/lib/model/om/BaseMyTablePeer.php on line 120
' => new sfWidgetFormInputHidden(),
));

    $this->setValidators(array(
      'name'   => new sfValidatorString(array('max_length' => 150, 'required' => false)),
      'id' => new sfValidatorBoolean(array('required' => false)),
      '
Notice: Undefined offset: 3 in /home/my_project/lib/model/om/BaseMyTablePeer.php on line 120
'     => new sfValidatorPropelChoice(
Notice: Undefined offset: 3 in /home/my_project/lib/model/om/BaseMyTablePeer.php on line 120
array('model' => 'MyTable', 'column' => '', 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('my_table[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    parent::setup();
  }

  public function getModelName()
  { 
    return 'MyTable';
  } 
} 

This Notice is due to an outbound call on translateFieldName of lib/model/om/BaseMyTablePeer.class.php
/**
* holds an array of fieldnames
*
* first dimension keys are the type constants
* e.g. self::$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
*/
private static $fieldNames = array (
BasePeer::TYPE_PHPNAME => array ('Name', 'Active', 'Id', ),
BasePeer::TYPE_STUDLYPHPNAME => array ('name', 'active', 'id', ),
BasePeer::TYPE_COLNAME => array (self::NAME, self::ACTIVE, self::ID, ),
BasePeer::TYPE_RAW_COLNAME => array ('NAME', 'ACTIVE', 'ID', ),
BasePeer::TYPE_FIELDNAME => array ('name', 'active', 'id', ),
BasePeer::TYPE_NUM => array (0, 2, 3, )
);

    /**
     * holds an array of keys for quick access to the fieldnames array
     *
     * first dimension keys are the type constants
     * e.g. self::$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
     */
    private static $fieldKeys = array (
            BasePeer::TYPE_PHPNAME => array ('Name' => 0, 'Active' => 2, 'Id' => 3, ),
            BasePeer::TYPE_STUDLYPHPNAME => array ('name' => 0, 'active' => 2, 'id' => 3, ),
            BasePeer::TYPE_COLNAME => array (self::NAME => 0, self::ACTIVE => 2, self::ID => 3, ),
            BasePeer::TYPE_RAW_COLNAME => array ('NAME' => 0, 'ACTIVE' => 2, 'ID' => 3, ),
            BasePeer::TYPE_FIELDNAME => array ('name' => 0, 'active' => 2, 'id' => 3, ),
            BasePeer::TYPE_NUM => array (0, 2, 3, )
    );

    /**
     * Translates a fieldname to another type
     *
     * @param      string $name field name
     * @param      string $fromType One of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME
     *                         BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM
     * @param      string $toType   One of the class type constants
     * @return     string translated name of the field.
     * @throws     PropelException - if the specified name could not be found in the fieldname mappings.
     */
    static public function translateFieldName($name, $fromType, $toType)
    {
            $toNames = self::getFieldNames($toType);
            $key = isset(self::$fieldKeys[$fromType][$name]) ? self::$fieldKeys[$fromType][$name] : null;
            if ($key === null) {
                    throw new PropelException("'$name' could not be found in the field names of type '$fromType'. These are: " . print_r(self::$fieldKeys[$fromType], true));
            }
            return $toNames[$key];
    }

I don't know which index was called at form generation time to produce this Notice but it seems that Form generation is willing to translate i18n field "description" as any common field of MyTable object (and that would be great for admin generator !)

One strange thing is that generating the forms and only forms again
./symfony propel:build-forms
Changes BaseMyTableForm.class.php content - removing the notice but adding a non named field as shown below :
$this->setWidgets(array(
'name' => new sfWidgetFormInputText(),
'id' => new sfWidgetFormInputCheckbox(),
'' => new sfWidgetFormInputHidden(),
));

$this->setValidators(array(
  'name'   => new sfValidatorString(array('max_length' => 150, 'required' => false)),
  'id' => new sfValidatorBoolean(array('required' => false)),
  ''     => new sfValidatorPropelChoice(array('model' => 'MyTable', 'column' => '', 'required' => false)),
));

That field should be the i18n field called "description" in my schema.
Any Idea about this issue ?
Loïc

Can't define more than one connection in a schema file

Hi,

If i try to define 2 connections in the same schema.yml file, the build-model only generate the first connection.

Ex:

#schema.yml
cona:
  _attributes:        {package: lib.model.cona}
  my_table:
    _attributes:      { phpName: ConAMyTable}
    id:               ~
    name:             {type: varchar(45)} 
conb:
  _attributes:        {package: lib.model.conb}
  my_table:
    _attributes:      { phpName: ConBMyTable}
    id:               ~
    name:             {type: varchar(45)} 
[/var/www/dev/test]$ ls lib/model/
cona

If i split the definitions :

# cona.schema.yml
cona:
  _attributes:        {package: lib.model.cona}
  my_table:
    _attributes:      { phpName: ConAMyTable}
    id:               ~
    name:             {type: varchar(45)} 

# conb.schema.yml
conb:
  _attributes:        {package: lib.model.conb}
  my_table:
    _attributes:      { phpName: ConBMyTable}
    id:               ~
    name:             {type: varchar(45)} 
[/var/www/dev/test]$ ls lib/model/
cona  conb

Migration/Installation problem - phing include path

Just installed sfPropelORMPlugin.
Environment:
symfony 1.4.14
PHP 5.3.5-1ubuntu7.2 with Suhosin-Patch (cli)

Followed instructions. But when I issue the command

php symfony plugin:publish-assets

I get the following error:

PHP Warning:  require_once(phing/BuildException.php): failed to open stream: No such file or directory in /home/luca/workspace/PHP/epod/plugins/sfPropelORMPlugin/lib/vendor/propel/generator/lib/exception/EngineException.php on line 11
PHP Stack trace:
PHP   1. {main}() /home/luca/workspace/PHP/epod/symfony:0
PHP   2. include() /home/luca/workspace/PHP/epod/symfony:14
......
PHP  14. require_once() /home/luca/workspace/PHP/epod/plugins/sfPropelORMPlugin/lib/vendor/propel/generator/lib/model/VendorInfo.php:12
PHP Fatal error:  require_once(): Failed opening required 'phing/BuildException.php' (include_path='/home/luca/workspace/PHP/epod:/home/luca/workspace/PHP/epod/plugins/sfPropelORMPlugin/lib/vendor/propel/runtime/lib:/usr/share/php:/usr/share/pear') in /home/luca/workspace/PHP/epod/plugins/sfPropelORMPlugin/lib/vendor/propel/generator/lib/exception/EngineException.php on line 11
PHP Stack trace:
PHP   1. {main}() /home/luca/workspace/PHP/epod/symfony:0
PHP   2. include() /home/luca/workspace/PHP/epod/symfony:14
...

Changing config/sfPropelORMPluginConfiguration.class.php in this way:

//change this line
//sfConfig::get('sf_phing_path', realpath(dirname(__FILE__).'/../lib/vendor/phing/classes')),
//to this:
sfConfig::get('sf_phing_path', realpath(dirname(__FILE__).'/../lib/vendor'))

seems to solve the problem.

task need further config option

In ProjectConfiguration, following instructions for SVN way, you need to add this line (among others):

sfConfig::set('sf_propel_generator_path', sfConfig::get('sf_root_dir') . '/lib/vendor/propel/generator/lib');

otherwise some tasks fail with this error:

Fatal error: require_once(): Failed opening required 'config/GeneratorConfig.php'

Configuration is used by sfPropelBaseTask.class.php at line 477

Propel 1.6 I18n behavior + symfony 1.4 fixtures loading issue

Hi François,
I noticed a workaround while working with fixtures and the sfPropel15Plugin with propel 1.6 embedded : commonly culture field name "culture" will throw an error at data import time since new name for culture is "locale".
It is not a bug, but could break compatibility with older projects already built around the "culture" field.
Loïc

Swift_PropelSpool: unserialize expects string not resource upon project:send-emails

I don't know how to make Pull request nor commit any changes so can one of you Git Gurus please help.

To fix error of:

Warning: unserialize() expects parameter 1 to be string, resource given in /.../plugins/sfPropelORMPlugin/lib/mailer/Swift_PropelSpool.class.php on line 117

when trying to send an email queue using Swift_PropelSpool

./symfony project:send-emails

factories.yml

mailer:
  param:
    delivery_strategy: spool
    spool_class:       Swift_PropelSpool
    spool_arguments:   [ MailMessage, message ]

Change line 117 of Swift_PropelSpool.class.php to reflect closer the main symfony sfPropelPlugin

Line 117 :

$message = unserialize($object->$method());

Change to :

if (is_resource($object->$method()))
{
    $message = unserialize(stream_get_contents($object->$method()));
}
else
{
    $message = unserialize($object->$method());
}

mergeRelation and nested versionable behavior leads to infinite loop

First of all, thanks for keeping Propel alive, you're doing an amazing job here.

I tried to use out of the box forms with mergeRelation on tables with versionable behavior, and there append to be an infinite loop between both isVersioningNecessary functions.
I guess there is something to do with alreadyInSave value that should be set to true somewhere.

To fix this in my app, I've just overridden the isVersioningNecessary of one model to remove the related model check as this needs to be unidirectional only.

I do not know what's the best workflow to use for this, but I thought it worthed being reported.

Julien

Wired BaseForm generated files

Hi, when i use the propel:build-forms command propel adds 2 lines inside the BaseXXXForm.class.php

Warning: call_user_func(IndumentiPeer::getUniqueColumnNames): First argument is expected to be a valid callback in /Users/ernestocasareto/Sites/eventsmanagement/plugins/sfPropel15Plugin/lib/generator/sfPropelFormGenerator.class.php on line 485

Warning: Invalid argument supplied for foreach() in /Users/ernestocasareto/Sites/eventsmanagement/plugins/sfPropel15Plugin/lib/generator/sfPropelFormGenerator.class.php on line 485

always at lines 33 and 35

Problem with UTF-8 handling

I have an existing working project migrated from sfPropel15Plugin to sfPropelORMPlugin, after rebuilding the model and importing the fixtures there is something very wrong with the character encoding. All special UTF-8 characters in objects loaded by Propel become '?'.

So if I do:
$a = MyObjectQuery::create()->findOne(); $b = $a->getTitle();

If $b in the db is "ąęść" the output is "????". Degrading to Propel15Plugin solves the issue. Would like a test-case project to see the problem?

Base*I18N.php vs. Base*I18n.php

It seems like the build task generates base classes using the naming schema "Base_I18n.php" instead of "Base_I18N.php". That's what broke our deployment yesterday, because our model classes still require()'d the old format.

While it was not a big deal to change the file names in our model classes, I think there should be an option to choose the naming schema to provide full compatibility to older version of the plugin.

symfony propel:diff undefined index 'disabled'

Running this task I get "Undefined index: disabled in {...................}/plugins/sfPropel15Plugin/lib/vendor/propel-generator/lib/model/Behavior.php on line 97"

last stack trace
SfPropelBehaviorBase->isDisabled() /home/tomasz/workspace/stickerous/plugins/sfPropel15Plugin/lib/behavior/SfPropelBehaviorI18n.php:60

Behavior->getParameter() /home/tomasz/workspace/stickerous/plugins/sfPropel15Plugin/lib/behavior/SfPropelBehaviorBase.php:51

Propel 1.6 I18n behavior + symfony1.4 propel:build-all issue

Hi François,
While attempting to use Propel1.6 embedded in sfPropel15Plugin on a symfony 1.4.9 project, we met several problems at classes generation time.
Mainly :

  • form/base/BaseMyTableI18nForm.class.php
    A method called getUniqueColumnNames() is missing (we temporarily resolved it by adding that method to model/MyTableI18nPeer.php class)
  • filter/base/BaseMyTableFormI18nFilter.php
    A call to BaseMyTableI18nPeer.php method translateFieldName() tries to call outbound fields that in fact are not defined in MyTablePeer but in MyTableI18nPeer

Those two problems generates warnings / notices that break generated base filters and forms.
Loïc

Manipulating PrimaryKey in Form

It's currently possible to update other objects rather than the to the form passed object by manipulating the primaryKey Hidden field in the html-code before submitting the form.

Symfony allready fixed this issue about a year ago in the standard sfPropelPlugin. I've noticed it was never fixed in sfPropel15Plugin. Would it be possible to fix this in sfPropel15Plugin too?

Best wishes,
Tschebel

Index: lib/generator/sfPropelFormGenerator.class.php
===================================================================
--- lib/generator/sfPropelFormGenerator.class.php   (revision 4333)
+++ lib/generator/sfPropelFormGenerator.class.php   (working copy)
@@ -328,10 +328,14 @@
         $name = 'Pass';
     }
 
-    if ($column->isPrimaryKey() || $column->isForeignKey())
+    if ($column->isForeignKey())
     {
       $name = 'PropelChoice';
     }
+    else if ($column->isPrimaryKey())
+    {
+      $name = 'Choice';
+    }
 
     return sprintf('sfValidator%s', $name);
   }
@@ -353,7 +357,7 @@
     }
     else if ($column->isPrimaryKey())
     {
-      $options[] = sprintf('\'model\' => \'%s\', \'column\' => \'%s\'', $column->getTable()->getClassname(), $this->translateColumnName($column));
+      $options[] = sprintf('\'choices\' => array($this->getObject()->get%s()), \'empty_value\' => $this->getObject()->get%1$s()', $this->translateColumnName($column, false, BasePeer::TYPE_PHPNAME));
     }
     else
     {

'hide_on_new' should be used in embedRelation()

Class is sfFormPropel

The 'hide_on_new' option is checked only in getRelationForm() method, while it should be checked also in embedRelation().
Adding these lines after line 558:

if ($this->getObject()->isNew() && $options['hide_on_new'])
{
  return;
}

it's OK, otherwise embedRelation() calls anyway getRelationForm() and getRelationForm() returns null, resulting in a fatal error

Fatal error: Call to a member function getCollection() on a non-object in /[...]/plugins/sfPropel15Plugin/lib/form/sfFormPropel.class.php on line 646

sfPropelDatabaseTest error

There's a typo in the test:

class ProjectConfiguration extends sfProjectConfiguration
{
  protected $plugins = array('sfPropelPlugin');
}

But even changing sfPropelPlugin to sfPropelORMPlugin test fails.
It seems that sfProjectConfiguration is looking for the plugins dir in the wrong place. Maybe this one is related to #59 and to #60

Propel 1.6 and Symfony 1.4 I18n

Hi,
I can't write a schema that works for both Propel 1.6 and Symfony 1.4 I18n.

I added the I18n behaviour, but now all the forms are not internationalized and I get the error "The model "Biografie" is not internationalized."

My schema is now:

biografie:
id: ~
user_id: { type: integer, foreignTable: sf_guard_user, foreignReference: id, required: true, index: unique, onDelete: cascade }
_propel_behaviors:
timestampable: ~
i18n: { locale_alias: culture, locale_column: culture, i18n_table: biografie_i18n, i18n_phpname: BiografieI18n, i18n_columns: "estratto, biografia", default_locale: it_IT }

I also tried:

biografie:
id: ~
user_id: { type: integer, foreignTable: sf_guard_user, foreignReference: id, required: true, index: unique, onDelete: cascade }
_propel_behaviors:
timestampable: ~
i18n: { locale_alias: culture, locale_column: culture }
biografie_i18n:
id: { type: integer, required: true, primaryKey: true, foreignTable: biografie, foreignReference: id }
estratto: { type: longvarchar }
biografia: { type: longvarchar }

But nothing works.
I know Propel 1.6 is not built FOR symfony but on http://www.propelorm.org/wiki/Documentation/1.6/Behaviors/i18n#SymfonyCompatibility i found that "This behavior is entirely compatible with the i18n behavior for symfony" so I assume forms should work as well.

How can I write it to make it work?
Thank you
Ernesto

Introducing sfPropelORMPlugin

Hi there,

The current sfPropel15Plugin plugin is available at http://www.symfony-project.org/plugins/sfPropel15Plugin but it is not synchronized with this repository. We should mark it as "deprecated" or to synchronize it with this Github repository.

Moreover, this plugin works with both Propel 1.5 and 1.6. The name of this plugin is not really consistent. People who wants a symfony plugin for Propel 1.6 often misses this plugin and that's bad.

Today, the SVN repository is no more maintained and SVN users have to use the SVN access feature provided by Github. But, Github is not able to offer a full-featured SVN service and to create an external on a specific directory seems impossible.

That's why we should change the sfPropel15Plugin to a new plugin named sfPropelORMPlugin which will probably breaks BC. Actually, it will be more consistent to have a plugin with that name and we will change the vendor directory structure from:

lib/vendor
 |_ propel
 |_ propel-generator 
 |_ phing

to:

lib/vendor
 |_ propel
 |    |_ runtime/lib
 |    |_ generator
 |
 |_ phing

So, it will solve the problem for both Git and SVN users as we will be able to create submodules or externals from Github repositories. But yes, it will break BC.

It's not really a problem for SVN users that uses the plugin from www.symfony-project.org because they are not up to date and it will give them a chance to be up to date :)
It's not a problem for Git users as they are not able to use submodules for propel and propel-generator directories expect with a non official repository synchronized with SVN. Note that the plugin will contain a submodule for the Propel lib.

For me the problem is about how to maintain both sfPropel15Plugin and sfPropelORMPlugin ? Should we do or should we arbitrary rename this repository and the plugin for sfPropel15Plugin to sfPropelORMPlugin with a README file that explains how to update ?

I'm +1 for the last assertion but it won't be a one man decision.

Regards,
William.

i18n behavior doesn't work

Hi,
I'm trying to use Propel 1.6 in my new Symfony project. I have this schema.yml:

propel:
  test:
    id: ~
    name: { type: varchar }
    _propel_behaviors:
      i18n: { i18n_columns: [ name ] }

If I build the schema, the i18n behavior is completely ignored and no test_i18n table is created.
Can someone help me trying to solve this issue?
Thanks!

sfWidgetFormPropelChoice::peer_method option "ignored" (exist but not working!)

Hi,

In sfWidgetFormPropelChoice "peer_method" option is ignored. The only way to know it is to examine the code of sfWidgetFormPropelChoice class (!).

This is a very bad practice. The option should work, disapear or throw an exception. Either, it introduce unvisible bugs in projects using it.

I spent 1 hour to discover that this option disapear. Moreover, I use this option in a plugin used in many websites using propel 1.4, propel 1.5 or propel 1.6.

In order that this plugin work on all website works on all websites I will have to rewrite all forms using sfWidgetFormPropelChoice to avoid "peer_method" option. Then propel 1.5 & 1.6 plugins are not backward compatible with 1.4

Sorry to be angry but I will have spent hours because of that...

Option --connection doesn't work in Form/Filter Generator

Hi,

Here is the schema :

# cona.schema.yml
cona:
  _attributes:        {package: lib.model.cona}
  a_table:
    _attributes:      { phpName: ConATable}
    id:               ~
    name:             {type: varchar(45)} 

# conb.schema.yml
conb:
  _attributes:        {package: lib.model.conb}
  b_table:
    _attributes:      { phpName: ConBTable}
    id:               ~
    name:             {type: varchar(45)} 

and the tasks :

[~/dev/test]$ php symfony propel:build-forms --connection="cona"
>> propel    generating form classes
>> tokens    /var/www/dev/test/lib/form/BaseFormPropel.class.php
>> tokens    /var/www/dev/test/lib/form/cona/base/BaseConATableForm.class.php
>> tokens    /var/www/dev/test/lib/form/cona/ConATableForm.class.php
>> tokens    /var/www/dev/test/lib/form/conb/ConBTableForm.class.php
>> tokens    /var/www/dev/test/lib/form/conb/base/BaseConBTableForm.class.php
>> file+     /var/www/dev/test/lib/form/BaseForm.class.php
>> tokens    /var/www/dev/test/lib/form/BaseForm.class.php
>> autoload  Resetting application autoloaders
>> autoload  Resetting CLI autoloader

[~/dev/test]$ php symfony propel:build-filters --connection="cona"
>> propel    generating filter form classes
>> tokens    /var/www/dev/test/lib/filter/BaseFormFilterPropel.class.php
>> tokens    /var/www/dev/test/lib/filter/cona/ConATableFormFilter.class.php
>> tokens    /var/www/dev/test/lib/filter/cona/base/BaseConATableFormFilter.class.php
>> tokens    /var/www/dev/test/lib/filter/conb/ConBTableFormFilter.class.php
>> tokens    /var/www/dev/test/lib/filter/conb/base/BaseConBTableFormFilter.class.php
>> autoload  Resetting application autoloaders
>> autoload  Resetting CLI autoloader

I think the problem is the same as the issue #84 : loadBuilders function in sfPropelFormGenerator load all tableMaps instead of filter them by connection name.

connection pooling parameter broken

Found this really old symfony ticket while researching a problem I was having with connection pooling. The problem still remains. http://trac.symfony-project.org/ticket/6040

When defining two databases in my database.yml the last database defined determines the setting of propels connection pooling.
Example database.yml:

all:
  propel:
    class: sfPropelDatabase 
    param:
      dsn: mysql:dbname=test;host=localhost 
      username: test 
      password: test 
      encoding: utf8 
      persistent: true 
      pooling: true 
      classname: PropelPDO

  test2:
    class: sfPropelDatabase 
    param:
      dsn: mysql:dbname=test2;host=localhost 
      username: test 
      password: test 
      encoding: utf8
      persistent: true
      pooling: FALSE
      classname: PropelPDO

so I now have defined two database connections, first propel connected to test, pooling true then test2 connected to test2, pooling false

line 66 in symfony/lib/plugins/sfPropelPlugin/lib/database/sfPropelDatabase.class.php checks the state of pooling everytime:

if ($this->getParameter('pooling', false))

and modifies the value of the singleton

Propel::disableInstancePooling();

overriding the value of the base connection...

Propel:diff task issues

It seems like the prope:diff task uses propel.ini instead of databases.yml to determine the database address, user and pass. This is not consistent with the way symfony works.

The generated schema classes are not removed after propel:diff has finished executing.

And one minor issue, the output of the task is mangled:
propel "PropelMigration_1298619657.php...esomeDGServ\lib/model/migration
propel Please review the generated S...ta migration code if necessary.
propel Once the migration class is v...el:migrate" task to execute it.

version column needs to be required for mssql

Hello,
there is a problem with versionable fields and mssql.
If version_column isn't required I get this error from mssql:

Cannot define PRIMARY KEY constraint on nullable column in table 'example_example_version'.
Could not create constraint. See previous errors.

Setting the version_column to required in VersionableBehavior.php fixed the issue.

Table name collision in Form/Filter Generators

Hi,

I have two connetions with two tables with de same name, like this :

# cona.schema.yml
cona:
  _attributes:        {package: lib.model.cona}
  my_table:
    _attributes:      { phpName: ConAMyTable}
    id:               ~
    name:             {type: varchar(45)} 
# conb.schema.yml
conb:
  _attributes:        {package: lib.model.conb}
  my_table:
    _attributes:      { phpName: ConBMyTable}
    id:               ~
    name:             {type: varchar(45)} 

the build-model works fine and build the models :

[~/dev/test]$ find lib/model/ -maxdepth 2 -name *.php
lib/model/cona/ConAMyTableQuery.php
lib/model/cona/ConAMyTable.php
lib/model/cona/ConAMyTablePeer.php
lib/model/conb/ConBMyTablePeer.php
lib/model/conb/ConBMyTableQuery.php
lib/model/conb/ConBMyTable.php

But the build-forms and build-filter don't work as well :

[~/dev/test]$ find lib/form/ -maxdepth 2 -name *.php
lib/form/BaseForm.class.php
lib/form/BaseFormPropel.class.php
lib/form/cona/ConAMyTableForm.class.php
[~/dev/test]$ find lib/filter -maxdepth 2 -name *.php
lib/filter/BaseFormFilterPropel.class.php
lib/filter/cona/ConAMyTableFormFilter.class.php

I think the problem is located in the loadBuilders function in sfPropelFormGenerator: the DatabaseMap is hydrated with all tableMaps instead of those of the tables under the selected connection.

embedding i18n forms is not possible

when i try to embed i18n forms i get the following error:

The model "Offer" is not internationalized.

my schema:


<database name="propel" defaultIdMethod="native">
 <table name="offer">
   <column name="id" type="integer" required="true" primaryKey="true" autoIncrement="true" />
   <column name="name" type="varchar" size="255" primaryString="true" />
   <behavior name="i18n">
     <parameter name="i18n_columns" value="name" />
   </behavior>
 </table>
</database>

the offer form:


class OfferForm extends BaseOfferForm {
  public function configure() {
    $this->embedI18n(array('nl_BE','fr_BE'));
  }
}

I've tried adding isI18N and I18Ntable, but no success.
I haven't found a working solution yet.
Any help is appreciated.

Kind regards,
Stijn

Typo in "Git way" installation

Having "git version 1.7.4.1" and command: git submodule init --update doesn't work but shows usage.
In docs I've found it should be git submodule update --init instead, which is working for me.

Not sure if these are just typos or git versions differences but there are more commands in README.md which should be checked.

Broken form with embedRelation(), if several relations define the same empty_label option

I've noticed a case when a form is broken by some - not so special - options given to embedRelation() :

<?php
$this->embedRelation('ContactPhone', array(                                                  
  'title'       => 'Phone numbers',
  'empty_label' => 'New', // notice that the empty_label is the same for both embedRelation
  'add_link'    => 'Add',
  'delete_name' => 'Delete'
)); 

$this->embedRelation('ContactMail', array(
  'title'       => 'Mail',
  'empty_label' => 'New',
  'add_link'    => 'Add',
  'delete_name' => 'Delete'
)); 

The problem is that if we declare several embedRelation with the same empty_label option, the generated code for the add link looks is the same for the two relations :

<a href="#" id="add_New_link" onclick="addNewWidget();return false;">
  Ajouter
</a>

The id and the onclick attribute are generated by using the empty_label option, and when we have two or more relations with the same, all the "add links" have the same id and onclick event.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.