This forum is in READ-ONLY mode.
You can look around, but if you want to ask a new question, please use the new forum.
Today's Messages (OFF)  | Unanswered Messages (ON)

Forum: symfony 1.1
 Topic: symfony 1.1 merge forms and labels problem
icon5.gif  symfony 1.1 merge forms and labels problem [message #55875] Thu, 10 July 2008 09:42
maxiu69  is currently offline maxiu69
Messages: 3
Registered: July 2008
Junior Member
I have two classes of forms. ProductForm and PriceForm. In PriceForm I have changed all field labels (inside the PriceForm class). Then I merged these forms. After the merge all labels from PriceForm are lost - default labels instead of them.

How to merge to forms without the lost of labels?

B.R.
maksymilian
 Topic: widget "somevalue" does not exist
widget "somevalue" does not exist [message #55913] Thu, 10 July 2008 17:03
tatanajllo  is currently offline tatanajllo
Messages: 13
Registered: July 2008
Junior Member
Hi well I've been looking for this over the past couple of days, at the beginning I thought I could ignore it, but now I applied js and it's become mayhem Shocked

My main form gets the number of embedded forms that I want displayed, so once the user hits save, it should display the desired number of embedded forms. Here is the code I'm using on the form (Main Form):

$numbCells is the value passed when main form is initially saved

class UnitForm extends BaseUnitForm
{

protected $childForms;

public function setup()
{
$childForms = array();
parent::setup();
}

public function getChildForms()
{
return $this->childForms;
}

public function configure()
{
..... some code


for($i=0; $i < $numbCells; $i++)
{
$newForm = new CellForm();

/* Embedding cell Form */
$newForm->setDefault('unit_key',$this->getObject()->getUnitKey());

$this->childForms[]=$newForm;

$this->embedForm('cells', $newForm);

}

}

}

Now this works but on the dev environment once I hit the save button I get: (x number is the first cell key number)

[InvalidArgumentException]
Widget "cells(x number)" does not exist.
stack trace

But when I refresh the page and open again everything is cool, embedded forms work good.

On the user environment I have to save, refresh form, save, refresh form (not fun).

I saw an answer by Fabien and I think I pretty much got it covered on the above code, since I am creating a new form for each cell, but still doesn't work.

Should I manipulate the cellForm configure, I didn't see it as necessary as I'm doing this through my embedding code.

Any help will be greatly appreciated.
 Topic: new Propel behavior method on Peer class
icon5.gif  new Propel behavior method on Peer class [message #55914] Thu, 10 July 2008 17:09
karl  is currently offline karl
Messages: 48
Registered: March 2006
Location: Lille, France
Member
Hello,

I need to add a new method to a peer class via a propel Behavior.
It is easy to add one to an Object class but on priori, it is impossible for Peer classes Mad . Have a look at this cookbook page for more information about it ("Add new methods" paragraph).

Here is my problem :
I made a plugin (some kind of PropelParanoidBehavior) that overrides the doSelectRS Peer method to select only the Objects related to the Dimension I'm in. (ysfDimensionPlugin... but that's not important here)
I'd like to add a "doSelectAll" method to the peer class that let me select all the related objects and not only the ones related to the dimension.

Has anyone found a trick to bypass this problem ?

Thx for your help Smile
 Topic: Form + UserId (background)
Form + UserId (background) [message #55915] Thu, 10 July 2008 17:14
freakx0  is currently offline freakx0
Messages: 77
Registered: November 2006
Location: Germany
Member
I've build a form through propel.

In my database-table is a field for the user-id. i want to save the id of the user which submitted the data.

But how can i do that with the new form-builder?

 Topic: Problems with loading data from fixtures
Problems with loading data from fixtures [message #55918] Thu, 10 July 2008 17:44
drola  is currently offline drola
Messages: 1
Registered: July 2008
Location: Slovenia, Zagorje
Junior Member
I have some issues with loading data from fixtures using doctrine (through sfDoctrinePlugin). I'm not sure if I have made some mistake or there's a bug.

My schema file looks like that:
detect_relations: on
options:
  collate: utf8_unicode_ci
  charset: utf8

Person:
  actAs:
    Sluggable:
      unique: true
      fields: [first_name, last_name]
      canUpdate:true
  columns:
    id:
      primary: true
      autoincrement: true
      type: integer
    first_name: string(255)
    last_name: string(255)
    email: string(255)

Article:
  actAs:
    Sluggable:
      unique: true
      fields: [title]
      canUpdate: true
  columns:
    id:
      primary: true
      autoincrement: true
      type: integer
    title: string

ArticleContent:
  actAs:
    Timestampable:
      created:
        disabled: true
      updated:
        name: updated_at
  columns:
    id:
      primary: true
      autoincrement: true
      type: integer
    person_id: integer
    article_id: integer
    content: string
  relations:
    Article:
      foreignAlias: article_contents
    Person:
      foreignAlias: article_contents



and data.yml look like that:
Person:
  mdrolc:
    first_name: Matjaž
    last_name: Drolc
    email: mdrolc@gmail.com
    article_contents:  [ fizika101, hw01 ]
  jkranjski:
    first_name: Janez
    last_name: Kranjski
    email: janez.kranjski@hotmail.com
    article_contents: [ fizika102 ]

Article:
  hw:
    title: Pozdravljen svet!
    article_contents: [ hw01 ]
  fizika1:
    title: Fizika v 1. letniku gimnazij
    article_contents: [ fizika101, fizika102 ]


ArticleContent:
  fizika101:
    content: Fizika je ql!
  fizika102:
    content: Ne pa ni!
  hw01:
    content: Pozdravljeni vsi!


When I run "./symfony doctrine:build-all-reload frontend", data is inserted, but article_id fields in ArticleContent table are filled with NULLs instead of article ids. On the other hand, links between persons and article contents are created without problems. If I exlude them from fixture file, there's no problem with links between articles and article's contents. Why can't be fields for both relations filled?
 Topic: Ajax Validation with new sfForms
Ajax Validation with new sfForms [message #55926] Thu, 10 July 2008 19:59
joostdj  is currently offline joostdj
Messages: 44
Registered: November 2007
Member
I normally use the sfYzAjaxValidationPlugin to arrange AJAX validation of my forms, according to the .yml validation-files.

Is there any alternative for Symfony 1.1 yet?? In 'The symfony Forms Book' it isn't mentioned.

Thanx!
 Topic: Pb Admin generator on many to many with Doctrine Nested Set and I18n
Pb Admin generator on many to many with Doctrine Nested Set and I18n [message #55976] Fri, 11 July 2008 13:20
global01  is currently offline global01
Messages: 3
Registered: July 2008
Junior Member
Hi Guys,

I'd like to have an admin_double_list for my I18n nested Set Category and i don't manage to do it!
Any Ideas?

By the way i'm using http://trac.symfony-project.org/wiki/HowToHandlei18nDbFields WithAdminGeneratorMethod2

Schema:
Category:
  actAs:
    NestedSet:
      hasManyRoots: true
      rootColumnName: root_id
    SoftDelete:
    Timestampable:
    I18n:
      fields: [title]
      actAs:
        Sluggable:
          fields: [title]
  columns:
    domain_id:
      type: integer(1)
      unsigned: true
    title: string(255)
    expired_at: timestamp
  indexes:
    domain_id:
      fields: [domain_id]

generator.yml
generator:
  class:              sfDoctrineAdminGenerator
  param:
    model_class:      Category
    theme:            default

    list:
      title:            "Category List"
      list:      
      display:
        "NONE": [id, title_i18n_en]
        "Title":
          - title_i18n_en
          - title_i18n_fr
      fields:        
        title_i18n_en:
          name: English
          params: disabled=false
        title_i18n_fr:
          name: French
          params: disabled=false

    edit:
      title:            "Category properties"
      edit:      
      display:
        "NONE": [Category] //???????
        "Title":
          - title_i18n_en
          - title_i18n_fr
        "Description":
          - introduction_i18n_en
          - introduction_i18n_fr
      fields:
        Category: doctrine_admin_double_list  // ?????????   
        title_i18n_en:
          name: English
          params: disabled=false
        title_i18n_fr:
          name: French
          params: disabled=false
        introduction_i18n_en:
          name: English
          type: textarea_tag
          params: disabled=false size=100x4
        introduction_i18n_fr:
          name: French
          type: textarea_tag
          params: disabled=false size=100x4

fixtures:
Category:
  Category_0:
    domain_id: 1
    Translation:
      en:
        title: Project
      fr:
        title: Projet
 
    children:
      Category_1:
        domain_id: 1
        Translation:
          en:
            title: xxxxxxx
          fr:
            title: xxxxxxxxxx
      Category_2:
        domain_id: 1
        Translation:
          en:
            title: xxxxxxxxx
          fr:
            title: xxxxxxxxxxx
       
        children:
          Category_3:
            domain_id: 1
            Translation:
              en:
                title: xxxxxxxx
              fr:
                title: xxxxxxxxxxx
 Topic: Creating a select tag in a partial?
Creating a select tag in a partial? [message #55992] Fri, 11 July 2008 19:06
ice_j7  is currently offline ice_j7
Messages: 116
Registered: February 2008
Location: Arequipa - Perú
Senior Member
How can i create a select tag in a partial?,

I'm digging into the form's framework core code, and the unique manner to do this is:

<?php
$s 
= new sfWidgetFormSelect(array('choices' => array('1' => '1''2' => '2''3' => '3''4' => '4')));
              echo 
$s->render('max_per_page'$sf_params->get('max'))
?>


but it looks terribly ugly to instantiate and object in a template. Personally I missed the form helpers rapid syntax in a template for anything that is not inside a form, so i think i could do a helper select_tag() (like Symfony 1.0) but using sfWidgetFormSelect in its definition, so we use all the right things.
Please comment about this here, i would like your feedback about this idea or maybe i just not search well enough and there is a better way to do it.

Regards


Search in the code, find wisdom.
 Topic: Fieldset Form Widget
Fieldset Form Widget [message #55995] Fri, 11 July 2008 21:57
nloyola  is currently offline nloyola
Messages: 1
Registered: July 2008
Junior Member
Just curious if anybody has thought about or has implemented a <fieldset> widget with the new form framework? If so are there any examples?

Thanks much
 Topic: How I can pass object from action to AbcForm::configure() method.
How I can pass object from action to AbcForm::configure() method. [message #56014] Sat, 12 July 2008 11:22
Whisller  is currently offline Whisller
Messages: 3
Registered: June 2008
Location: Warsaw, Poland
Junior Member

Hi,
I have a logical problem with new form classes.
In action ( execute method ) I get an object. This object I must use in AbcForm class in configure method.
So first what I did was create __construct method in my AbcForm class, with one parameter.
<?php
public function __construct($myObject) {
  
parent::__construct();
  
  
$this->myObject $myObject;

  echo 
' AbcForm::__construct ';
}
?>


And my configure method
<?php
public function configure() {
  echo 
' AbcForm::configure() ';
  
  
# var_dump($this->myObject);
}
?>


But after created new instance of AbcForm class in action ( $this->form = new AbcForm($myObject) )
I saw on page
AbcForm::configure() AbcForm::__construct

So I cannot get access $this->myObject object in configure :/

Any solutions?

Best regards,
Whisller.

[Updated on: Sat, 12 July 2008 11:23]

 Topic: upgrade to symfony 1.1. with pear "failed", but symfony "works"
upgrade to symfony 1.1. with pear "failed", but symfony "works" [message #56018] Sat, 12 July 2008 13:05
abash  is currently offline abash
Messages: 15
Registered: May 2006
Location: Moscow, Russia
Junior Member

I have no idea:

site ~ # symfony -V
symfony version 1.1.0 (/usr/lib/php5/share/pear/symfony)


site ~ # pear info symfony/symfony
No information found for `symfony/symfony'


site ~ # pear install symfony/symfony
Skipping package "symfony/symfony", already installed as version
No valid packages found
install failed


site ~ # pear -v upgrade symfony/symfony
downloading symfony-1.1.0.tgz ...
Starting to download symfony-1.1.0.tgz (2,130,238 bytes)
......................................done: 2,130,238 bytes
ERROR: pear.symfony-project.com/symfony not installed


site ~ # pear uninstall symfony/symfony

Fatal error: Call to a member function resetDirtree() on a non-object in /usr/share/php/PEAR/Installer.php on line 835


I really don't understand what is wrong. But i still does not report some bugs which i head after upgrade because I not sure - is it a bug or my environment problem.

Does any one have something like this?

[Updated on: Sat, 12 July 2008 13:06]


And for the time it was good...
 Topic: No release available for plugin "" in state "" that satisfies the application re
No release available for plugin "" in state "" that satisfies the application re [message #56020] Sat, 12 July 2008 14:27
abash  is currently offline abash
Messages: 15
Registered: May 2006
Location: Moscow, Russia
Junior Member

I recently moved to symfony 1.1.

site~ /var/www/project $ symfony plugin-install sfSimpleCMSPlugin
>> plugin    installing plugin "sfSimpleCMSPlugin"


  No release available for plugin "sfSimpleCMSPlugin" in state "beta" that satisfies the application requirements.

Does it mean that i should wait the plugin authors to migrate the plugin to 1.1. ?
Or, is there any config option to allow 1_0 compatibility?
like

compat_10:              on


And for the time it was good...
 Topic: AddCredential and CSRF protection
icon5.gif  AddCredential and CSRF protection [message #56027] Sat, 12 July 2008 17:40
pentium133  is currently offline pentium133
Messages: 8
Registered: June 2008
Junior Member
After submit my form, I call function sfUser->AddCredential (in filter) and symfony core call session_regenerate_id function.

And after appear CSRF validatuon error Sad

[Updated on: Sat, 12 July 2008 17:41]

 Topic: hasFiles() in 1.1
icon5.gif  hasFiles() in 1.1 [message #56067] Mon, 14 July 2008 05:07
norbu09  is currently offline norbu09
Messages: 1
Registered: July 2008
Junior Member
hi,

i try to find a way around the problem that hasFiles() does not exist in 1.1 anymore. my problem is that i generate my forms on the fly so i have no defined filed names. is there a way to get hasFiles() in 1.1 without calling the compat_10 thing and without writing code that uses deprecated API calls?

thanks
lenz
 Topic: symfony working with multiple schemas and views on PostgreSQL - symfony 1.1
symfony working with multiple schemas and views on PostgreSQL - symfony 1.1 [message #56150] Mon, 14 July 2008 20:13
patrickespake  is currently offline patrickespake
Messages: 49
Registered: January 2008
Location: Brasil
Member

symfony 1.1

http://trac.symfony-project.org/wiki/HowToPatchSymfony1.1ToT hePostgreSQLWorkingMultipleSchemas


Patrick Espake
patrickespake@gmail.com
http://patrickespake.wordpress.com
 Topic: How to create a required marker in forms?
How to create a required marker in forms? [message #56154] Mon, 14 July 2008 20:53
Seikilos  is currently offline Seikilos
Messages: 609
Registered: May 2008
Location: Germany
Faithful Member
When outputting forms with echo $forms; there is no marker for required fields, something like

* Name: <input>

Is there way to add that kind of output? Or is the only way by overriding the output of the form by myself?


Debugging is all I doֻ (if these dots are not in line then your screen is broken)
 Topic: How to specify helper in generator.yml
How to specify helper in generator.yml [message #56158] Mon, 14 July 2008 21:06
moussa1979  is currently offline moussa1979
Messages: 2
Registered: August 2006
Junior Member
Hi,

How can i specify helper (ie DateForm Helper) in generator.yml file.

Thanks.
 Topic: How to build a plug-in symfony 1.1?
How to build a plug-in symfony 1.1? [message #56178] Tue, 15 July 2008 00:00
patrickespake  is currently offline patrickespake
Messages: 49
Registered: January 2008
Location: Brasil
Member

I'm updating my plugins made to version 1.0 of symfony to the version 1.1.

Much has changed in the construction of plugins, I could not find a good documentation that explains how to build a plugin for the symfony 1.1 and talk about the sfTask.

Can anyone help?

How do i build a plugin? There is a How to?


Patrick Espake
patrickespake@gmail.com
http://patrickespake.wordpress.com
 Topic: New field not appearing on form
New field not appearing on form [message #56222] Tue, 15 July 2008 12:54
dagger  is currently offline dagger
Messages: 8
Registered: July 2008
Junior Member
Hi,

I am a beginner on symfony (so bear with me)... i have created a project with 2 tables/models
user:
 id:
 email: varchar(100)
 password: varchar(100)

article:
 id:
 user_id:
 title: varchar(100)
 body: longvarchar


now - i initially forgot the user_id field and i build-models and also the forms... every thing worked fine... but now when i added the user_id field in schema.yml (also updated the database) and build-model along with forms- the form of article does not show the user_id ... the BaseArticleForm contains the

$this->setWidgets(array(
      'id'              => new sfWidgetFormInputHidden(),      
      'title'           => new sfWidgetFormInput(),
      'body'            => new sfWidgetFormInput(),
      'user_id'         => new sfWidgetFormPropelSelect(array('model' => 'User', 'add_empty' => true)),
    ));


user_id field but the form does not show the field ... is this how is it suppose to behave??? or is there something wrong...


would highly appreciate the help - thanks

[Updated on: Tue, 15 July 2008 19:55]


replication is stupid... reusability is perfect!
 Topic: Spyc not working
Spyc not working [message #56253] Tue, 15 July 2008 19:02
patrickespake  is currently offline patrickespake
Messages: 49
Registered: January 2008
Location: Brasil
Member

I need to use a class Spyc.class.php. As I do this in symfony 1.1?

Spyc not working more in symfony 1.1.

What do i do?

  private function merge($pFirstFile, $pSecondFile)
  {
    if(is_file($pFirstFile) && is_file($pSecondFile))
    {
      // Load yaml files for arrays
      $_spyc = new Spyc();
      $_firstYaml  = $_spyc->load($pFirstFile);
      $_secondYaml = $_spyc->load($pSecondFile);

      // Merge arrays
      $_endYaml = $this->_mergeArrays($_firstYaml, $_secondYaml);

      // Generate YAML
      return Spyc::YAMLDump($_endYaml, true);
    }
  }


Patrick Espake
patrickespake@gmail.com
http://patrickespake.wordpress.com
 Topic: My first application error
My first application error [message #56264] Tue, 15 July 2008 23:51
filtro  is currently offline filtro
Messages: 1
Registered: July 2008
Junior Member
I'm trying to learn symfony. I've tried the tutorial My first application, but I have some big issues.
First when I try to insert a comment symfony return me this error:
Post id
Fatal error: Call to undefined method Post::__toString() in /Library/WebServer/Documents/sf_sandbox/lib/symfony/plugins/ sfPropelPlugin/lib/propel/widget/sfWidgetFormPropelSelect.cl ass.php on line 88

I did't edit files I used only the terminal comand, so that sounds strange.

I tried to continue, but I met a new problem.
Tutorial ask me to edit executeShow method into sf_sandbox/apps/frontend/modules/post/actions/actions.class. php file
but this method there isn't, so I tryed to add it.

but tutorial continues asking to edit sf_sandbox/apps/frontend/modules/post/templates/showSuccess. php template
but it there isn't.

I don't understand if there is some errors, or I'm doing some mistakes. Is there some expert user that tried to complete the tutorial using symfony 1.1 version?
Thanks
Fil
 Topic: GRUD generation and Undefined variable cache
icon4.gif  GRUD generation and Undefined variable cache [message #56275] Wed, 16 July 2008 06:38
gEndelf  is currently offline gEndelf
Messages: 9
Registered: June 2008
Junior Member
Hi !

I'm trying to generate CRUD for models but error is occured

command:
symfony propel:generate-crud backend news News --with-show


Notice: Undefined variable: cache in E:\dev\servers\xampp\php\pear\symfony\generator\sfGeneratorManager.class.php on line 65
  Failed to make cache directory "".


folders log and cache are R+W
models and forms already generated

after trying to resolve this challenge I see that generator try to create folders in cache smth like this

E:\dev\projects\commerse\portal\trunk\cache\tmp\a14339244ff536642629f8977475028a\autoNews/actions/actions.class.php


a14339244ff536642629f8977475028a - exists, but autoNews and actions doesn't

plz help to resolve Smile

[Updated on: Wed, 16 July 2008 08:38]

 Topic: sfWebDebug example please
sfWebDebug example please [message #56318] Wed, 16 July 2008 17:21
pkobor  is currently offline pkobor
Messages: 2
Registered: July 2008
Junior Member
Just upgraded to 1.1. Not sure how to use sfWebDebug to log my own debug messages, can someone provide an example??
 Topic: possible BUG in sfPropelUniqueValidator ???
icon3.gif  possible BUG in sfPropelUniqueValidator ??? [message #56362] Thu, 17 July 2008 00:15
vekili  is currently offline vekili
Messages: 2
Registered: July 2008
Junior Member
Sorry if this is already known thing, or I am not using things properly...

I am using admin generator with validation (and sfPropelUniqueValidator for one of the fields). Briefly, the problem is that the name for the primary key generated in edit form is not the same as parameter gathered from request in sfPropelUniqueValidator. (line 58, 61) The result is that every time an entry is edited, validator reports error.

Everything would work great if I used the same name for the column in database and in object for the primary key. I don't like naming column in database just "id", but it is totally OK for the object property.

Let's see the example:

schema.yml:

propel:
...
groups:
_attributes: { phpName: Group }
group_id: { phpName: Id, peerName: ID, type: integer, required: true, primaryKey: true, autoIncrement: true }
name: { type: varchar, size: 255, required: true, index: unique }
description: { type: longvarchar }
...


validate/edit.yml:

methods:
post:
- "group{name}"

names:
group{name}:
required: yes
required_msg: Please, enter a name
validators: nameUniqueValidator

nameUniqueValidator:
class: sfPropelUniqueValidator
param:
class: Group
column: name
unique_error: This group name already exists



The problem is that every time an existing entry is edited, it reports the unique error. The field for the primary key in the generated form is "id", and the validator tries to get the value of (BasePeer::TYPE_FIELDNAME) "group_id" request parameter.
The parameter "group_id" does not exist in the form, so it will not be matched as the same entry in the database.

I probably didn't do something right (maybe with schema.yml, or there could be some other options in generator.yml), but it just seamed wrong to me that generator is using one naming rule for the form fields, and the Validator tries to get parameters by database column name???

I usually don't post messages on forums, but I really like symfony and would like to contribute (even if it is a small thing like spotting a possible bug Smile )

Thanks!
 Topic: Any Input escaping?
Any Input escaping? [message #56365] Thu, 17 July 2008 06:57
Seikilos  is currently offline Seikilos
Messages: 609
Registered: May 2008
Location: Germany
Faithful Member
I know that symfony has output strategies (which are turned on), they escape my output data, which is great. But does symfony provide a way to escape input?
If I access my software by /module/action?parameter=something
are there any ways, symfony helps me with escaping the parameters? Or must I do that by hand?


Debugging is all I doֻ (if these dots are not in line then your screen is broken)
 Topic: if I originally did "generate-crud" but now wish I'd done "init-admin" how do I
if I originally did "generate-crud" but now wish I'd done "init-admin" how do I [message #56502] Sat, 19 July 2008 03:30
lkrubner  is currently offline lkrubner
Messages: 297
Registered: July 2008
Location: Virginia, USA
Faithful Member

So, I'm working on my first Symfony project. I'm stumbling around a bit in the dark. Having established my database and schema.xml, I then generated a crud scaffolding:

symfony propel-generate-crud ftpmonitor ftpuploads FtpUploads

But now that I understand things better, I want to undo that and instead do something like:

symfony propel-init-admin ftpmonitor ftpuploads FtpUploads

What do I need to do to undo the "propel-generate-crud" command? Do I just delete all the files and clear the cache?



Symfony Experts offers answers: http://www.symfonyexperts.com/
 Topic: why do I get "supplied argument is not a valid MySQL result resource "
why do I get "supplied argument is not a valid MySQL result resource " [message #56535] Sun, 20 July 2008 05:38
lkrubner  is currently offline lkrubner
Messages: 297
Registered: July 2008
Location: Virginia, USA
Faithful Member

When I run this command:

php symfony propel:build-schema --xml


I most get the right output, but I also get three of these:


[PHP Error] mysql_fetch_assoc(): supplied argument is not a valid MySQL result resource [line 55 of /usr/share/pear/symfony/plugins/sfPropelPlugin/lib/vendor/cr eole/drivers/mysql/metadata/MySQLTableInfo.php]



why?



Symfony Experts offers answers: http://www.symfonyexperts.com/
 Topic: Filter -> Sanitizing Parameters? Custom filter for module?
Filter -> Sanitizing Parameters? Custom filter for module? [message #56733] Tue, 22 July 2008 16:14
Seikilos  is currently offline Seikilos
Messages: 609
Registered: May 2008
Location: Germany
Faithful Member
I need to sanitize input for several modules, it can be get or post and I have no idea how to do that effectively.
I am thinning about to use a filter that escapes common problems but if i have modules which require a param to be an integer, is there a way to create a filter for that module? Or is the only way to do that by writing code into the module itself?

And what is a common way to sanitize input in an action file? I mean sure, I use one of the sfValidators, thats not the problem, but how can I modify the contents of the sfRequest? For instance, if somebody injected chars into a parameter which should be a number, i could throw an error or just set this value to zero but is the request object read/write or read only?


Debugging is all I doֻ (if these dots are not in line then your screen is broken)
 Topic: symfony 1.1 not call lib sfPHPView
symfony 1.1 not call lib sfPHPView [message #56779] Wed, 23 July 2008 01:13
patrickespake  is currently offline patrickespake
Messages: 49
Registered: January 2008
Location: Brasil
Member

This code not working in symfony 1.1.

$this->getContext()->getRequest()->setAttribute($this->getRequestParameter('target_module').'_'.$this->getRequestParameter('target_action').'_view_name', 'sfJavascript', 'symfony/action/view');


What is the correct way to symfony 1.1?


Patrick Espake
patrickespake@gmail.com
http://patrickespake.wordpress.com
 Topic: sfCompat10Plugin sfFillInForm: error for multiple select
icon4.gif  sfCompat10Plugin sfFillInForm: error for multiple select [message #56813] Wed, 23 July 2008 10:54
schtefan  is currently offline schtefan
Messages: 1
Registered: July 2008
Location: Erlangen, Germany
Junior Member
After redisplaying a select element with multiple selection processed by sfFillInForm (from sfCompat10Plugin), only the first item formerly selected is selected again, all other items formerly selected are unselected. The bug is located in sfFillInForm.class.php, sfFillInForm::getValue; if the block
Quote:

protected function getValue(&$values, $name, $shiftArray = false)
{
[...]
/* BEGIN MODIFICATION
* if ($shiftArray && is_array($return))
* {
* // we need to remove the first element from the array. Therefore we need a reference
* return array_shift($return);
* }
* END MODIFICATION */
[...]

is commented out or removed, the behaviour is as expected, all formerly selected items are also selected after redisplaying the form.
 Topic: Credential for form fieds and default values
Credential for form fieds and default values [message #56835] Wed, 23 July 2008 14:35
loic66  is currently offline loic66
Messages: 15
Registered: July 2008
Location: Lyon
Junior Member
Hi everyone,

I have some problems with credentials and forms.
In my database I have articles with some fields that should only be edited by an administrator.
A user should only be able to edit the articles that he has created.
I am using Symfony 1.1 with the sfGuardPlugin.

To avoid users to edit articles of which they are not the authors, I add this lines in my actions.class.php (I am not sure that it is the right way to do it, but it works) and create two formulars, one for the admin and one for the normal users

actions.class.php
<?php
$user 
$this->getUser()->getGuardUser();
    if(
$user->getId() == $auteur->getId() || $this->getUser()->hasCredential('admin')){
      if(
$this->getUser()->hasCredential('admin'))
      {
        
$this->form = new AnnonceForm($annonce);
      }else{
        
$this->form = new AnnonceEnregistreForm($annonce);
      }
    }else{
      
$this->redirect('annonce/publie');
    }
?>


lib/form/AnnonceForm.php for the admin (all the fields)
<?php
class AnnonceForm extends BaseAnnonceForm//Propel form
{}
?>

lib/form/AnnonceEnregistreForm.php for the other user
<?php
class AnnonceEnregistreForm extends AnnonceForm
{
  public function 
configure(){
    
parent::configure();
    unset(
$this['user_id']);
    unset(
$this['niveau']);
    unset(
$this['publie']);
    unset(
$this['created_on']);
  }
}
?>


I want that a normal user can not edit the followings fields, user_id, niveau, publie, created_on so I unset them in the configure() methods and that works because the constructor of the form initialised the unset fields with the previous values.
But when a user wants to create a new article, the database insertion request fails because theses fields are not initialised and they are required.
user_id should be the id of the user creating the article
publie should be false
niveau should be 0
and created_on the current date

Is it possible to force these fields to theses values and how?

My schema.yml
#articles table
 ac_annonce:
    _attributes: {phpName: Annonce}
    id:
    user_id:
      type: integer
      required: true
      foreignTable: sf_guard_user
      foreignReference: id
      onDelete: cascade
    titre:
      required: true
      type: longvarchar
    contenu:
      required: true
      type: longvarchar
    niveau:
      type: integer
      required: true
      default: 0
    publie:
      type: boolean
      default: false 
      required: true
    created_at:
 Topic: change post_id by name of post
change post_id by name of post [message #56912] Thu, 24 July 2008 09:46
Real_Time  is currently offline Real_Time
Messages: 3
Registered: July 2008
Location: Hà Nội
Junior Member
i was successfull my first symfony project. When i point to list comment it show:
comment id/post id coment name / .......

but i want to change post id to post name how can i do that???

thanks to read.
 Topic: sfContext::getCurrentViewInstance in symfony 1.1 ?
sfContext::getCurrentViewInstance in symfony 1.1 ? [message #56939] Thu, 24 July 2008 15:50
zero0x  is currently offline zero0x
Messages: 36
Registered: October 2007
Member

Hi, how do I get current view instance in symfony 1.1 ?

In symfony 1.0, I used sfContext::getInstance()->getCurrentViewInstance();

--

I've been browsing through symfony1.1 source code, and I found only sfController::getView, but it requires moduleName, actionName and viewName, and I don't really know what should I pass as these parameters.

I just want the current view instance ...


ubuntu rules
 Topic: sfWidgetFormDate
sfWidgetFormDate [message #56941] Thu, 24 July 2008 16:02
Profundum  is currently offline Profundum
Messages: 3
Registered: June 2008
Junior Member
Hi,

I've been going through the book and the API docs but I cannot see, if possible, how to render a rich date selector. Is this still possible?

I've also noticed that sfValidatorDate also fails to calculate correctly if a date comes after another. I used the code directly from the forms tutorials on this site.


Any help appreciated.
Thanks,
David
 Topic: More Validation Troubles from the Front Lines...
More Validation Troubles from the Front Lines... [message #56948] Thu, 24 July 2008 16:51
DigitalMechanic  is currently offline DigitalMechanic
Messages: 38
Registered: February 2008
Location: USA
Member
I'm using sfValidatorPropelChoice, but in order to set up the criteria, I need to know the values of other form fields (which have already validated). So I setValidators after the form is bound, and then try this, expecting it to throw an sfValidatorErrorSchema:
$this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

Should I be trying some other call? After I update the validators and try to get them to run, I want check
form->isValid() and form[field]->getError() to get the details, but they are always empty/ok.

Any thoughts are appreciated...

Thanks,

-DM
 Topic: admin_input_file_tag %%id%% with Foreign Key Constraints
admin_input_file_tag %%id%% with Foreign Key Constraints [message #56953] Thu, 24 July 2008 17:42
PHPDev  is currently offline PHPDev
Messages: 8
Registered: October 2007
Junior Member
After upgrading to 1.1 I now have Foreign Key Constraints on the in the database. and when attempting to upload a file via the generated admin I get a FK Constraint error on the insert.

Here is the code that was working under 1.0

Admin generator.yml
 edit:
      fields:
        event_date:
          name:       'Event Date'
        title:
          params:     size=50
        image:
          name:       'Event Image'
          type:       admin_input_file_tag
          params:     size=40
          upload_dir:  events
          filename:    %%id%%


class eventsActions extends autoeventsActions
{
	protected function updateEventsFromRequest()
	{
		if( !$this->getRequestParameter('id') )
		{
			$this->events->setTitle('');
			$this->events->save();
		} // end if
		
		parent::updateEventsFromRequest();
	} // end function
}


I guess I should have said that the events are grouped by categories and therefore have a FK to categories.id via categories_id on the Events table.

I can understand why the FK constraint fails, but how does one go about fixing it

I tried setting the FK from the form like

$this->events->setCategoriesId($this->getRequestParameter('categories_id'));

obviously that did not work... actually it did not set the FK properly.

Thanks

PHPdev
 Topic: customizing form generation process
customizing form generation process [message #57153] Mon, 28 July 2008 13:19
cthulhu  is currently offline cthulhu
Messages: 48
Registered: February 2006
Member
Hi,
i'm looking for a way to have symfony generate form classes with custom default validators and widgets in place of sfWidgets and sfValidators.
E.G. For every string field of the model class, generate in the form a customStringWidget with a customStringValidator.

Thanks
Giorgio
 Topic: propel:generate-crud throws Undefined offset exception
propel:generate-crud throws Undefined offset exception [message #57259] Tue, 29 July 2008 15:18
igor.varga  is currently offline igor.varga
Messages: 1
Registered: July 2008
Junior Member
Hi,

I stumbled upon this behavior recently:

I have a model named Document and all classes and forms are generated by propel:build-all for that model.

After that I modify the DocumentForm class like this:

public function configure()
{
  unset($this['created_at']);
  unset($this['path']);
}


When I run the "propel:generate-crud backend document Document", following exception occurs:

PHP Notice: Undefined offset: 5 in C:\Program Files\PHP\PEAR\symfony\generator
\sfAdminGenerator.class.php on line 768

You can find the entire stack trace attached.

I searched the forums and tickets for the same error with no results.

When I uncomment the unset in the configure method, the generator works fine. Exception occurs in the getLastNonHiddenField() and from a brief look it seems that positions and form arrays are not synchronized in this case.

Conclusion is that either propel:generate-crud should be used only with "virgin" form classes, this is a bug in generator, or I am doing something wrong.

Any suggestions?

  • Attachment: out.txt
    (Size: 4.56KB, Downloaded 146 time(s))

 Topic: Grouping items with the new form system
Grouping items with the new form system [message #57271] Tue, 29 July 2008 16:34
dream0r  is currently offline dream0r
Messages: 3
Registered: July 2008
Junior Member
I'm exploring the new form system. But I can't find a possibility to group 'widgets'. I would like to group them in a fieldset, or at least give them a 'group' label. Someone know where to find this functionality ? Or how to implement it myself?
 Topic: generate-crud + i18n forms
generate-crud + i18n forms [message #57336] Wed, 30 July 2008 14:54
bregoiu  is currently offline bregoiu
Messages: 1
Registered: July 2008
Junior Member
I'm using symfony 1.1 with the following schema:
propel:
  news:
    _attributes: { phpName: News, isI18N: true, i18nTable: news_i18n }
    id:          { type: integer, required: true, primaryKey: true, autoincrement: true }
    created_at:
  news_i18n:
    _attributes: { phpName: NewsI18n }
    id:          { type: integer, required: true, primaryKey: true, foreignTable: news, foreignReference: id }
    culture:     { isCulture: true, type: varchar, size: 7, required: true, primaryKey: true }
    title:       { type: varchar, size: 255 }
    content:     { type: varchar, size: 255 }


I did:
propel:build-model
propel:build-forms
propel:generate-crud

but in the generated forms, there is no trace of the i18n fields?
Did I forget anything?

Pages (169): [ «  <  1  2  3  4  5  6  7  8  9  10  11  12  13  14  15  16  >  »]

powered by FUDforum - copyright ©2001-2004 FUD Forum Bulletin Board Software