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: postvalidator question
postvalidator question [message #63867] Fri, 24 October 2008 16:08
jefferson  is currently offline jefferson
Messages: 27
Registered: November 2007
Junior Member
how can i check if at least one of two fields is filled?
 Topic: [SOLVED] link_to() doesn't work well.
[SOLVED] link_to() doesn't work well. [message #63878] Fri, 24 October 2008 17:37
grenoult  is currently offline grenoult
Messages: 52
Registered: September 2008
Location: France
Member
Hi Smile

I've got a problem with the link_to() function.

For example, a link is supposed to move me on "myproject/web/back.php/incidents/create" but it leads me to "myproject/web/incidents/create" (with of course a 404 error (not the one of Symfony)).

My PHP code is the following :
<?php echo link_to("Incidents","incidents/create"); ?>


How can i resolved this problem ?

Thx Smile

EDIT : damn after surfing of Symfony forums for a few minutes, the link_to() helper works well... Shocked I don't understand... But it's solved Very Happy

[Updated on: Fri, 24 October 2008 17:47]

 Topic: tasks - access to base classes
tasks - access to base classes [message #63903] Fri, 24 October 2008 23:48
upalom00  is currently offline upalom00
Messages: 19
Registered: October 2008
Location: California
Junior Member
Hi

I'm trying to use tasks to run processes via the cmd line.

The goal is to grab data from a database, write it to another database, and send out an email to a list of users.

I'm not getting to far with this however - been bangin my head on the keyboard. Here is a snippet of code:

Right now i have the problem where the task doesn't have a clue what my base models are ...
The base models are located here:
<PROJECT>/lib/model/rt


class doNothingTask extends sfPropelBaseTask
{
protected function configure()
{
// i figured i needed to set the app env
$this->addArgument('application', sfCommandArgument::REQUIRED, 'Changes the application context of the task');

}

protected function execute($arguments = array(), $options = array())
{
// a doc said i need to set the db
$db = new sfDatabaseManager($this->configuration);

// emails from my customer table
$crit_cust_limit = new Criteria();
// when I run this, it complains that it doesn't know what CustomerPeer is ...
$crit_cust_limit->add(CustomerPeer::EMAIL, '%cisco%', Criteria::NOT_LIKE);
}
}
 Topic: How to upload a file thanks to an embedded form when not embedded works?
How to upload a file thanks to an embedded form when not embedded works? [message #63907] Sat, 25 October 2008 09:31
polix  is currently offline polix
Messages: 35
Registered: September 2008
Member
Hello,

I have a form that enables the user to upload a file. It means that the related class has the following line:

'file'  => new sfWidgetFormInputFile(),


in this->setWidgets() in the setup() function.


If I use this form alone, everything is ok, like in the tutorial (case [1]).
However, if I use this form as an embedded form, it does not work any longer (case [2]).

Here is my schema: main_form(sub_form(sub_sub_form_1, sub_sub_form_2)). It means that main_form embeds a form a type sub_form and sub_form embeds two other forms: one of type sub_sub_form_1 and one of type sub_sub_form_2.

My upload form is the one of type sub_sub_form_2.

The error message from Symfony is:

Quote:


[sfValidatorErrorSchema]
file [Required.]
stack trace

...




The validation of the form is not ok and I get the previous error message by forcing the save of the form, in this way:

$posted_data = $request->getParameter('main');
$ssf2_form->bind($posted_data['sub']['sub_sub_2'], $request->getFiles('main'));
if (/*$ssf2_form->isValid()*/true)
{
     $ssf2_form->save();
}


So the problem is that the files are not correctly handeled. Since the code is the same than for case [1].

To understand what's wrong, I used var_dump($request->getFiles('main')), in both cases.

Here are the results:

case [1]:
Quote:

array(5) { ["name"]=> array(1) { ["file"]=> string( 8 ) "info.txt" } ["type"]=> array(1) { ["file"]=> string(10) "text/plain" } ["tmp_name"]=> array(1) { ["file"]=> string(48) "D:\work\...\php65.tmp" } ["error"]=> array(1) { ["file"]=> int(0) } ["size"]=> array(1) { ["file"]=> int(513) } }



case [2]:
Quote:

array(5) { ["name"]=> array(1) { ["sub"]=> array(1) { ["sub_sub_2"]=> array(1) { ["file"]=> string( 8 ) "info.txt" } } } ["type"]=> array(1) { ["sub"]=> array(1) { ["sub_sub_2"]=> array(1) { ["file"]=> string(10) "text/plain" } } } ["tmp_name"]=> array(1) { ["sub"]=> array(1) { ["sub_sub_2"]=> array(1) { ["file"]=> string(63) "D:\work\...\php62.tmp" } } } ["error"]=> array(1) { ["sub"]=> array(1) { ["sub_sub_2"]=> array(1) { ["file"]=> int(0) } } } ["size"]=> array(1) { ["sub"]=> array(1) { ["sub_sub_2"]=> array(1) { ["file"]=> int(513) } } } }


Is there something in Symfony to deal with this problem?
If not, do you have an easy way to change the structure of this array to give it the same structure as in case [1]: an array of 5 elements: name, type, tmp_name, error and size and for each of these elements an array of 1 element called file?

Thanks in advance.

[Updated on: Sun, 26 October 2008 00:28]

 Topic: Problem with ajax comment function like askeet answers
Problem with ajax comment function like askeet answers [message #63926] Sun, 26 October 2008 00:55
Oliver_R  is currently offline Oliver_R
Messages: 1
Registered: October 2008
Junior Member
Hi all,

I am trying to implement my own blog with symfony and experience a problem with my ajax comment function.
I tried to implement it the same way as it is shown for answers in the askeed tutorial here: http://www.symfony-project.org/askeet/1_0/en/10

I dont know if it is just not working the same way in symfony 1.1 or if I made critical mistakes. When I input the values, the Indicater shows up as if the request was fine, but no new comment is showing up and nothing is saved in the database.
I gladly appreciate any help:


article->actions.class.php
public function executeShow()
{
$this->article = ArticlePeer::retrieveByPk($this->getRequestParameter('aid'));
$this->forward404Unless($this->article);
}


article->showsuccess.php
<?php use_helper('Javascript', 'Global', 'Date', 'User');?>
[...]
<tr>
<div class="comment" id="add_comment"></div>
<?php echo form_remote_tag(array(
'url' => '@add_comment',
'update' => array('success' => 'add_comment'),
'loading' => "Element.show('indicator')",
'complete' => "Element.hide('indicator');".visual_effect('highlight','add_comment'))) ?>
<td class="labelcomment">
<label for="label">Titel:</label></td>
<td><?php echo input_tag('header', $sf_params->get('header')) ?>
</td>
</tr>
<tr><td class="labelcomment">
<label for="label">Kommentar:</label></td>
<td><?php echo textarea_tag('body', $sf_params->get('body')) ?></td>
</tr>
</div>
<tr>
<td colspan="2" class="submitcomment">
<?php echo input_hidden_tag('article_id', $article->getAid()) ?>
<?php echo submit_tag('Kommentar abschicken') ?></td>
</tr>
</form>
[...]


comments->actions.class.php
public function executeAdd()
{
if ($this->getRequest()->getMethod() == sfRequest::POST)
{
if (!$this->getRequestParameter('body'))
{
return sfView::NONE;
}

$article = ArticlePeer::retrieveByPk($this->getRequestParameter('article_id'));
$this->forward404Unless($article);
if ($this->getUser()->hasAttribute('user'))
{
$user = $this->getUser()->getAttribute('user');
$uid = $user->getUid();
}
else $uid = $this->getUser()->getAttribute('author')->getAuid();



// create comment
$this->comment = new Comment();
$this->comment->setAid($article->getAid());
$this->comment->setHeader($this->getRequestParameter('header'));
$this->comment->setBody($this->getRequestParameter('body'));
$this->comment->setUid($uid);
$this->comment->setStatus('1');
if($this->comment->validate())
$this->comment->save();
$article->setAllcomments($article->getAllcomments()+1);

return sfView::SUCCESS;
}

Addsuccess.php:
<?php include_partial('comment', array('comment' => $comment)) ?>


comment schema:
comment:
_attributes: { idMethod: native }
CID: { type: INTEGER, required: true, autoIncrement: true, primaryKey: true }
UID: { type: INTEGER, required: true, default: '0', foreignTable: user, foreignReference: UID, onDelete: CASCADE, onUpdate: CASCADE }
AID: { type: INTEGER, required: true, default: '0', foreignTable: article, foreignReference: AID, onDelete: CASCADE, onUpdate: CASCADE }
Header: { type: VARCHAR, size: '255', required: true, default: '' }
Body: { type: LONGVARCHAR, required: true }
Status: { type: TINYINT, required: true, default: '0' }
created_at: {type: TIMESTAMP, required: true, default: CURRENT_TIMESTAMP}
_indexes: { AID: [AID], UID: [UID] }
 Topic: Odd Configuration Works - Have I Broken Something?
Odd Configuration Works - Have I Broken Something? [message #63934] Sun, 26 October 2008 10:14
benlumley  is currently offline benlumley
Messages: 6
Registered: October 2008
Junior Member
I'm using symfony (specifically the admin generator) to save me some time creating a backend app for an existing propel 1.3 application (non symfony).

I've installed propel 1.3 as per here so that the two are in sync:

http://www.symfony-project.org/blog/2008/05/30/how-do-i-use- propel-1-3-in-symfony-1-1

Once I'd followed those instructions, my databases.yml looked like:

dev:
  propel:
    param:
      classname:  DebugPDO

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


But this wasn't working - I kept getting propel exceptions saying runtime conf couldn't be found for database [123]. (from line 520 of Propel.php)

I hunted around a bit, and eventually tried echoing variables within Propel.php.

This led me to try this in my databases.yml

dev:
  abc:
    param:
      classname:  DebugPDO

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


Which worked ....

This isn't mentioned in the documentation anywhere - or if it is, its not very clear/easy to find.

This makes me think that its not supposed to be like this, so:

Is this a change due to propel 1.3?
Or have I got something amiss somewhere else in my config?

[Updated on: Sun, 26 October 2008 10:14]

 Topic: Render html with PHP
Render html with PHP [message #63950] Sun, 26 October 2008 18:41
maxxon  is currently offline maxxon
Messages: 2
Registered: October 2008
Junior Member
Hi,

How can I render this variable get from database?

action.class.php
$this->content = '<p><? echo link_to("text", "url") ?></p>';


indexSuccess.php
<h1>Header</h1>
<? echo $content ?>


HTML show this without parse the PHP code:
<h1>Header</h1>
<p><? echo link_to("text", "url") ?></p>

[Updated on: Fri, 31 October 2008 09:00]

 Topic: No connection params set for xxx when I know that's not the case!!!
No connection params set for xxx when I know that's not the case!!! [message #63958] Sun, 26 October 2008 21:14
DigitalMechanic  is currently offline DigitalMechanic
Messages: 38
Registered: February 2008
Location: USA
Member
I'm running 1.1.4 and PostgreSQL 8.3 - Ran into this problem like a brick wall - and it doesn't make any sense. I setup my project and after successfully executing several database-oriented symfony commands with no errors (and the expected results showing up in my database); the thing now decides it doesn't know how to connect to the db.

I was going through the Admin-Generator video - running right along side Fabien (pausing often because he's a quick one): I did the following steps (in order - translaing 1.0 commands for 1.1 commands of course)...
  1. symfony generate:project MyProject
  2. symfony generate:app MyAppName
  3. edit config/propel.ini, added propel.disableIndentifierQuoting=true
  4. modified propel.database = pgsql
  5. modified propel.database.createUrl = pgsql://user:pass@hostname/
  6. modified propel.database.url = pgsql://user:pass@hostname/dbname
  7. modified my config/databases.yml with correct connect string (no tabs!!!!)
  8. created my config/schema.yml (just one simple table)
  9. created a data/fixtures.yml to add a row of data
  10. created the database in pgsql (granted the user access to db and schema)
  11. did symfony propel:build-model (no errors)
  12. did symfony propel:build-sql (no errors)
  13. did symfony propel:insert-sql (no errors)
  14. did symfony propel:data-load appname (no errors)
  15. went to view the page and got the No connection params set for dbname (where dbname is the name used in all the connection params for the previous steps)...
  16. checked that the table was created (it was)
  17. checked perms (user has all privs)
  18. did symfony propel:init-admin appname modulename classname
  19. checked my pants to see if I remembered to put them on today (I did)


I have no idea why propel doesn't think it has params for a connection when it connected to do all the db stuff...

BTW: I did this again - but used build-schema to extract the schema content from an existing db and it worked flawlessly...

Anyone have any good migrane meds?

Please advise...

Thanks,

-DM

DigitalMechanic

[Updated on: Sun, 26 October 2008 21:34]

 Topic: Need help installing sfTextReplacementPlugin for symfony 1.1
Need help installing sfTextReplacementPlugin for symfony 1.1 [message #63965] Mon, 27 October 2008 04:11
zaktrak  is currently offline zaktrak
Messages: 21
Registered: June 2008
Junior Member
I just upgraded to symfony 1.1 and did my best to follow the instructions at http://www.symfony-project.org/installation/1_1/upgrade. But now I am getting this error:
Fatal error: Call to undefined method sfConfigCache::getinstance() in C:\wamp\www\herbal-nutrition\plugins\sfTextReplacementPlugin\config\config.php on line 2

I tried to clear the cache, but I got the same error at the command line.

I'm guessing that the plugin I had was only compatible with symfony 1.0, but I saw that the previous release supports sf 1.1 - http://www.symfony-project.org/plugins/sfTextReplacementPlug in/0_1_1. I tried to install by:
php symfony plugin:install sfTextReplacementPlugin --release=0.1.1 

But I get:
>> plugin    installing plugin "sfTextReplacementPlugin"

Unable to get plugin licence information for plugin "sfTextReplacementPlugin":
 Unknown package: "sfTextReplacementPlugin" (Debug: File http://plugins.symfony-project.org:80/REST/p/sftextreplacementplugin/info.xml not valid 
(received: HTTP .0 404 Not found
  )) (use --force-license to force installation)

So then I tried:
symfony plugin:install sfTextReplacementPlugin --re
lease=0.1.1 --force-license

and got:
>> plugin    installing plugin "sfTextReplacementPlugin"

  Unable to get dependencies information for plugin "sfTextReplacementPlugin": File http://plugins.symfony-project.org:80/REST/r/sftextreplacementplugin/deps.0.1.txt 
not valid (received: HTTP/1.0 404 Not found
  )


I did get the plugin by doing a svn checkout from http://svn.symfony-project.com/plugins/sfTextReplacementPlug in, but I don't know if it's for sf 1.0 or 1.1. It still doesn't work either way. If anyone can help me with plugin installation that would be great.

Thanks
 Topic: Conditional Validation - Either/Or Mandatory Fields?
Conditional Validation - Either/Or Mandatory Fields? [message #63997] Mon, 27 October 2008 14:00
bigm  is currently offline bigm
Messages: 40
Registered: April 2008
Location: Australia
Member
Hi All,

I've done quite a bit of ready and forum scouring, but so far have been unable to find a solution to this... I thought I was very very close when I discovered the sfValidatorOr / sfValidatorAnd, but the examples in the book only go as far as using 2 sfValidatorSchemaCompare validators inside of them, so I'm not really sure if it's possible (and if it is, what is the syntax) to have new validators for two separate fields.

The basic problem is I have two fields, and one or the other MUST be filled in... (Both can be filled in, but both can't be blank).

So I think basically I want two sfValidatorString checks (one on each field) inside an sfValidatorOr... but I'm not sure if this is possible, or how to do it if it is!

Any help very much appreciated.

Thanks,
JM


Regards,
JM
http://www.symfonynerds.com
 Topic: Creating a Multi-company application
Creating a Multi-company application [message #64002] Mon, 27 October 2008 15:12
dkurman  is currently offline dkurman
Messages: 10
Registered: October 2008
Location: Beccar - Buenos Aires - A...
Junior Member
Hi all. I need to create a multi-company application. I have the app made with symfony, with one database in mysql. I need to filter the data through the user authentication, but I donĀ“t know how to implement this using symfony. Any ideas?

Thanks in advance.
 Topic: How to use the doc...
How to use the doc... [message #64005] Mon, 27 October 2008 15:37
Flashball  is currently offline Flashball
Messages: 127
Registered: January 2008
Location: France
Senior Member
Hi,

I'm not understanding how I have to use the 1.1 documentation to find the informations I need.

For example, I tried to implement the sfCompareValidator in a form. I've read the doc about the new 1.1 form system, and I've learn that there is some parameters for each validator, some required, some optionnal.

When I go to the API doc, there is no information about theses required or optionnals fields: where can I found this information?

After making a test, I realize that this validator is not compatible with the 1.1 validation form: it's not easy to understand...

For example, I hope to implement something like that:

		$this->setValidators(array(
			'email' => new sfValidatorEmail(array(), array('required' => 'Courriel obligatoire.', 'invalid' => 'L\'adresse email est invalide.')),
			'email2' => new sfValidatorAnd(array(
				new sfValidatorEmail(array(), array('required' => 'Courriel obligatoire.', 'invalid' => 'La confirmation de l\'adresse email est invalide.')),
				new sfCompareValidator(array(), array('required' => 'Mot de passe obligatoire.', 'check' => 'email', 'operator' => '==', 'compare_error' => ''))
				)),
			'password' => new sfValidatorString(array(), array('required' => 'Mot de passe obligatoire.')),
			'password2' => new sfValidatorAnd(array(
				new sfValidatorString(array(), array('required' => 'Confirmation du mot de passe obligatoire.')),
				new sfCompareValidator(array(), array('required' => 'Mot de passe obligatoire.', 'check' => 'password', 'operator' => '==', 'compare_error' => ''))
				)),
		));


Thanks.

[Updated on: Mon, 27 October 2008 15:44]

 Topic: Warning: Illegal offset type in unset in....
Warning: Illegal offset type in unset in.... [message #64015] Mon, 27 October 2008 18:19
Scalp  is currently offline Scalp
Messages: 38
Registered: August 2008
Member
Hi,

I've a little problem with my Form management..

In my action i do it : "$form->offsetUnset($field);" on few fields (it's in a foreach).
But when i : "echo $form;" on my indexSuccess i've this kind of error :

Quote:

Warning: Illegal offset type in unset in /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php on line 547

Warning: Illegal offset type in unset in /usr/share/php/symfony/validator/sfValidatorSchema.class.php on line 327

Warning: Illegal offset type in unset in /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php on line 547

Warning: Illegal offset type in unset in /usr/share/php/symfony/validator/sfValidatorSchema.class.php on line 327

Warning: Illegal offset type in unset in /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php on line 547

Warning: Illegal offset type in unset in /usr/share/php/symfony/validator/sfValidatorSchema.class.php on line 327

Warning: Illegal offset type in unset in /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php on line 547

Warning: Illegal offset type in unset in /usr/share/php/symfony/validator/sfValidatorSchema.class.php on line 327

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php:5 47) in /usr/share/php/symfony/response/sfWebResponse.class.php on line 296

Warning: Cannot modify header information - headers already sent by (output started at /usr/share/php/symfony/widget/sfWidgetFormSchema.class.php:5 47) in /usr/share/php/symfony/response/sfWebResponse.class.php on line 310



I seek for a solution on web but without success... Sad

My class form is empty, i'vnt override 'BaseXxxForm.class.php'.


Thank you,
Sebastien.
 Topic: Country State City picker without putting every element to main table
Country State City picker without putting every element to main table [message #64031] Tue, 28 October 2008 00:32
dsotosek  is currently offline dsotosek
Messages: 5
Registered: September 2008
Junior Member
Hi guys!

Could somebody explain me please how to implement Country State City Picker without putting all three elements to the user's class.

This example is on that link:
http://blog.barros.ws/2008/10/26/countrystatecity-picker-in- symfony-11/

What would be the creation getState() and getCountry() methods?

Country and State should be just temporary selects for users to easily find the city.

I really have some difficulties of understanding what and how needs to be done!

Thank you in advance!
dsotosek
 Topic: Update a form element according to changing another element.
Update a form element according to changing another element. [message #64046] Tue, 28 October 2008 11:15
grenoult  is currently offline grenoult
Messages: 52
Registered: September 2008
Location: France
Member
Hi.

I've got a form with several inputs. One of them (a select/option list) is supposed to show or enable another element according to its value.

What is the cleanest way to do this ?

Thanks Smile
 Topic: Form how to add widgets and problem
Form how to add widgets and problem [message #64047] Tue, 28 October 2008 12:09
Murena  is currently offline Murena
Messages: 41
Registered: October 2008
Member
Hello,

I have some questions about forms.
I generated a form with propel, added validators and postvalidator and it works fine.

Is it possible to add a field not linked to database field? like password_again. What is the right way of doing this?

I tried to overwrite baseclass repeating the

$this->setWidgets(array()) construct and adding the password_again widget.
When I do this a strange thing happens. The form doens't validate anymore, it seems it doesn't get the parameters.




 Topic: Ajax dynamix list ?
Ajax dynamix list ? [message #64048] Tue, 28 October 2008 12:22
grenoult  is currently offline grenoult
Messages: 52
Registered: September 2008
Location: France
Member
Hello.

I have an index page containing all the items of my table. I'd like to change dynamically this page with constraints given by the user.

For example, i've a basic list :
item | name
-----------------------
1 | abc
2 | def
3 | ijk

When the user clicks to a link or a button requesting the SQL code "... WHERE item = 2;", the list should change (:

item | name
-----------------------
2 | def

How can i do that?

Thanks Smile
 Topic: i18n:extract mysql not saving tags
icon4.gif  i18n:extract mysql not saving tags [message #64055] Tue, 28 October 2008 15:20
f1xxx3r  is currently offline f1xxx3r
Messages: 2
Registered: October 2008
Junior Member
Hello,
I am having some issues with the i18n:extract task.
I have successfully used this function as a plugin in sf 1.0 before but in 1.1 I cannot manage to get the tags to be saved in the database.

all:
  i18n:
    class: sfI18N
    param:
     default_culture: en
     source: MySQL
     database: mysql://root@localhost/database_name
in factories.yml (these settings used to be in a i18n.yml file)

all:
  .settings:
    i18n:                   on
in settings.yml

When I run the symfony i18n:extract --auto-save backend en command the result i get is
>> i18n      extracting i18n strings for the "backend" application
>> i18n      found "46" new i18n strings
>> i18n      found "0" old i18n strings
>> i18n      saving new i18n strings
but the tags are not saved.

Can anyone point me to a sollution on this as I have not found anything regarding this issue on the forum or websearch.

Thank you very much.


LE:

I have comented the destructor in sfMessageSource_MySQL.class.php (line 131) because it was giving me a lot of warnings. I have done it like this in the sf 1.0 days and it worked without problems.

[Updated on: Wed, 29 October 2008 15:47]

 Topic: textarea - default value from database
textarea - default value from database [message #64073] Tue, 28 October 2008 17:53
enriquelover  is currently offline enriquelover
Messages: 2
Registered: October 2008
Junior Member
hi,
I know its basic question but i cant figure it out, how to load dynamic generated data to textarea as default value?

i know i can declare css class this way:
$form['textarea']->renderRow(array('class'=>'some_class')) 


or set value in input form this way:
$form['input_form']->renderRow(array('value'=>'some default value')) 


but how to set default value for textarea?

oh, i found it. For sure i was read about it earlier but i just forget about that, and wasn't able to find again.

Anyway the answer is:

in action.class.php
$this->form = new MyForm(array('textarea_name'=>'default_content'));

i alsow need to change in lib/form/MyForm.class.php from
class MyForm extends BaseMyForm

to
class MyForm extends sfForm


but now i dont know how to validate data after changing extends. Normal it is
$this->form = new MyForm(MyPeer::retrieveByPk($request->getParameter('id')));
 
    if ($request->isMethod('post'))
    {
      $this->form->bind($request->getParameter('author'));
      if ([B]$this->form->isValid()[/B])
      {
        $author = $this->form->save();
 
        $this->redirect('author/edit?id='.$author->getId());
      }
    }


unfortunately now its now working

[Updated on: Wed, 29 October 2008 02:17]

 Topic: From Validators
From Validators [message #64106] Wed, 29 October 2008 10:01
dmr99  is currently offline dmr99
Messages: 26
Registered: October 2008
Junior Member
Hey,

Is it possible to use/create a validator that will only be used when a condition is met. I have a form with 2 radio buttons. If the user selects option 1, i dont require validation. If the user selects option 2, i require some form fields to be validated (mainly just presence checks). I only want these presence checks to run if option 2 is selected...

Any help would be much appreciated

Thanks
 Topic: Export data via XML
Export data via XML [message #64117] Wed, 29 October 2008 11:26
freakx0  is currently offline freakx0
Messages: 77
Registered: November 2006
Location: Germany
Member
I've to export data via xml. i've seen that since sf1.1 there is the sf_format available. but i didn't find a howto or example how to provide a xml file. i can't use the feed2 plugin, because i need a special xml-schema.

how to do that?
 Topic: include_javascripts() and include_stylesheets() are not working properly
include_javascripts() and include_stylesheets() are not working properly [message #64139] Wed, 29 October 2008 14:53
klausherzberg  is currently offline klausherzberg
Messages: 11
Registered: July 2008
Junior Member
Hi,
I use

<?php include_javascripts(); ?>
<?php include_stylesheets(); ?>

in my /frontend/templates/layout.php

I do this to determine the place of style- and js-files and to have a browser switch after.

But: All the time I have all my style- and js-files 2 times in the html source.

Seems
sfConfig::set('symfony.asset.javascripts_included', true);
sfConfig::set('symfony.asset.stylesheets_included', true);

doesn't work?

Any idea.

Thanks.

Klaus.
 Topic: Different result between test:unit and test:unit myTest
Different result between test:unit and test:unit myTest [message #64145] Wed, 29 October 2008 15:25
cf357  is currently offline cf357
Messages: 14
Registered: October 2008
Location: Paris (France), Sliema (M...
Junior Member
Hi everyone,

I got a strange behaviour...

I recently wrote a test, called 'userTest', and when I launch the command "symfony test:unit", I get :

userTest............. .........dubious
Test returned status 255


and when I launch "symfony test:unit user", no problem.
This test is performing connections to the Database, creating / removing data.

Any idea ?

[Updated on: Wed, 29 October 2008 15:27]


Piwam, French association manager :
http://piwam.googlecode.com
 Topic: sfWidgetFormDateTime and a Javascript
sfWidgetFormDateTime and a Javascript [message #64154] Wed, 29 October 2008 18:00
sklefisch  is currently offline sklefisch
Messages: 11
Registered: August 2008
Location: Germany
Junior Member
Hi,
i have the following problem:

in my form class there are two sfWidgetDateTimes and i have to sync them in my template on value change.

here is my code snipped for the form class:
$this->setWidgets(array(...
'startdate' => new sfWidgetFormDateTime(array(),array()),
'enddate' => new sfWidgetFormDateTime(array(),array()),
));


this is the code snipped for the template:
<tr>
   <td>
      <?php echo $form['startdate']->renderLabel('Start:') ?>
      <?php echo $form['startdate']->render(array("onchange" => "selectOption()")); ?>
   </td>
</tr>
<tr>
   <td>
      <?php echo $form['enddate']->renderLabel('Ende:') ?>
      <?php echo $form['enddate'] ?>
   </td>
</tr>


this is the java script which should be executet
<?php echo javascript_tag("  						
   function selectOption()
   {  
      var startdate_month = document.getElementById('search_startdate_month');
      var startdate_day = document.getElementById('search_startdate_day');
      var startdate_year = document.getElementById('search_startdate_year');
							
      var enddate_month = document.getElementById('search_startdate_month');
      var enddate_day = document.getElementById('search_enddate_day');
      var enddate_year = document.getElementById('search_enddate_year');
	
      enddate_month.selectedIndex = startdate_month.selectedIndex;
      enddate_day.selectedIndex = startdate_day.selectedIndex;
      enddate_year.selectedIndex = startdate_year.selectedIndex;
						}
") ?>


BUT.... this doesn't work. someone has an idea why? maybe because the datetime can not handle(insert) the onchange for all the select's??? is it posible to call the 5 parts of the datetime widget one by one and add the attributes to each render method..? i tried the following : $form['startdate']['month']->render(array("onchange" => "selectOption()")); but got an error...

i made a small sample with just two normal select and the same javascript function an render call an i work perfectly!!!

PLEASE HELP....

regards,
Stefan
 Topic: Unsuccessful validation using edit.yml
Unsuccessful validation using edit.yml [message #64258] Thu, 30 October 2008 20:30
dimitris  is currently offline dimitris
Messages: 26
Registered: July 2008
Junior Member
Hi everyone,

i'm try to start using the admin generator and i've read the documentation but still i have some problem. when using just the generator.yml file everything seems to work.

generator.yml
generators:
  class:  sfPropelAdminGenerator
  param:
    model_class:  User
    theme: default

    fields:
      id: { name: ID }
      name: { name: Name }
      email: { name: Email  }
      invitations: { name: Invitations }
      created_at: { name: Created At }
      updated_at: { name: Updated At }

    list:
      title: List of all users
      max_per_page: 25

    edit:
      display: [name, email]


but since i want some simple validation both for the name and the email i want to use the edit.yml file. my edit.yml file is:

edit.yml
methods:
  post:
    - "user{name}"
    - "user{email}"

names:
  user{name}:
    required: true
    required_msg: You must provide a name
    validators: nameValidator

  user{email}:
    required: true
    required_msg: This is not a valid email address
    validators: emailValidator

nameValidator:
  class: sfValidatorString
  params:
    min: 2
    min_error: This name is too short (2 characters minimum)
    max: 100
    max_error: This name is too long (100 characters maximum)

emailValidator:
  class: sfValidatorEmail

fillin:
  activate: on


the result is that the validation is always unsuccessful whether i fill the form correctly the form or not or leave it empty. Is there anything wrong with my edit.yml file that i can't see? Thanks in advance!

[Updated on: Thu, 30 October 2008 22:13]

 Topic: I'm gona to know the custom Tag in symfony
I'm gona to know the custom Tag in symfony [message #64283] Fri, 31 October 2008 09:55
stc6895  is currently offline stc6895
Messages: 12
Registered: October 2008
Junior Member
Hey ,Every Developer

I'am comming again.

Here is some problem about custom Tag.

In developing. I've found the tag problem.
Sometimes we may use tag to producting our view templates
for example:
<com: Panel source:$panel>
<div >.......
</div>
</com>


so I have a question ....in recently..I'm using function to simulate that

<?php echo Panel_start($panel)?>
<div ......</div>
<?php echo Panel_end()?>


does symfony provide the customTag?

Thank you very much....





 Topic: how to set sfWidgetFormInputCheckbox unchecked?
how to set sfWidgetFormInputCheckbox unchecked? [message #64294] Fri, 31 October 2008 12:05
jefferson  is currently offline jefferson
Messages: 27
Registered: November 2007
Junior Member
here is my checkbox

$this->widgetSchema['autolink'] = new sfWidgetFormInputCheckbox(array('value_attribute_value' => 1));


how can i set it unchecked per default? (in best case it should be checked if object attribute is 1 und unchecked if 0)

the default value in db schema is 1
i'm experiencing the problem when the value is 0 and the box should be unchecked

[Updated on: Fri, 31 October 2008 12:33]

 Topic: Handle multiple checkboxes in a form
Handle multiple checkboxes in a form [message #64329] Fri, 31 October 2008 16:16
Sephi77  is currently offline Sephi77
Messages: 109
Registered: January 2007
Location: Switzerland
Senior Member
Hi everybody,

I'm trying to create a form which has 3 checkboxes on the same label, like a select tag but with checkboxes. The problem is that I just CAN'T find a way to do it correctly. I thought I could use the same syntax as radio buttons since that's exactly what I want to do (but with checkboxes instead of radio buttons) but that didn't work. I also tried to use an sfWidgetFormSchema to regroup my 3 checkboxes and then add them to the form, but the result was not what I was expecting (the HTML output is not correct).

I'm sure this must be very simple to do and that I missed something... thanks for your help.
 Topic: [solved] forms 1.1 datetime and actions
[solved] forms 1.1 datetime and actions [message #64355] Sat, 01 November 2008 10:17
lionslair  is currently offline lionslair
Messages: 89
Registered: October 2007
Location: Perth / Western Australia
Member
I really need some help because I am just not able to get around this issue. How do I update the date time value with imput received from sfWidgetFormDateTime


action

/**
   * Executes update action / edit Blog
   *
   */
  public function executeAlbumUpdate($request)
  {
    $this->forward404Unless($request->isMethod('post'));

    $this->form = new GalleryAlbumForm(GalleryAlbumPeer :: retrieveByPK($request->getParameter('id')), $this->getUser()->getLoginId());

    //$gallery_album = $this->form->getValues($request->getParameter('gallery_album'));
    //echo '<pre>'.$gallery_album['date'].'</pre>'; exit;
    //echo '<pre>'.$gallery_album['date'].'</pre>'; exit;
    $this->form->bind($request->getParameter('gallery_album'));
    //$this->form->bind($gallery_album);

    if ($this->form->isValid())
    {
      
      //$this->form = $this->form->getValues();
      
//      echo '<pre>form: '.print_r($this->form, true).'</pre>'; exit;

      $values = $this->form->getValues();
      
      //$this->form->setDate($values['date']['year'].'-'. $values['date']['month'] .'-'. $values['date']['day']);
      
      //echo '<pre>values: '.print_r($values, true).'</pre>'; exit;
      
      //echo '<pre>values: '.$values['date']['day'].'</pre>'; exit;
      
      $this->album = $this->form->save();

      $this->getUser()->setFlash('msg', $request->getParameter('id') ? 'Updated Album' : 'Added new album');
      $this->getUser()->setFlash('class', 'confirmation');

      $this->redirect($this->getModuleName(). '/myAlbums');
    }

    $this->gallery_album = $this->form->getObject();


    $this->setTemplate('albumEdit');
  } // end function executeGalleryAlbumUpdate
  


The way to do it is

 $values = $this->form->getValues();

$values['date'] = $values['date']['year'].'-'.$values['date']['month'].'-'.$values['date']['day'];

 $this->album = $this->form->bindAndSave($values);

[Updated on: Sun, 02 November 2008 23:58]


www.lionslair.net.au
 Topic: [solved] symfony cli not running.
[solved] symfony cli not running. [message #64380] Sun, 02 November 2008 02:35
lionslair  is currently offline lionslair
Messages: 89
Registered: October 2007
Location: Perth / Western Australia
Member
I have been running symfony 1.1 from the svn version. All of a sudden this morning running ./symfony from the console returns nothing nothing. not the symfony menu just nothing. Not even an error. I removed the location of the symfony core and did a svn update but this did not fix the issue.

Anyone know what is happening here?

Was an extra bracket in my execute function of a custom migration task. Was very hard to find and was a process of elimination. Was no debug or errors to let me know this was happening.

[Updated on: Sun, 02 November 2008 23:55]


www.lionslair.net.au
 Topic: specific routing rule or default action for iphone browser
specific routing rule or default action for iphone browser [message #64395] Sun, 02 November 2008 14:05
nsilberman  is currently offline nsilberman
Messages: 10
Registered: November 2007
Junior Member
Hi,

I'm wondering how I can execute an action depending of the brower.
I have read the symfony for iphone page, and now I need to execute a specific action different from the default action.

I know I can add a redirect directly in the indexSuccess.iphone.php to the right action, but I'm pretty sure I can do something better like :
- specific routing rule for iphone in routing.yml
- call a specific action directly in the executeIndex method

Does anybody have an idea ?

Thanks
 Topic: Where should I append my route programmatically?
Where should I append my route programmatically? [message #64423] Mon, 03 November 2008 09:17
Apfelbeisser  is currently offline Apfelbeisser
Messages: 37
Registered: March 2008
Member
I tried it in my application configuration by listening the load factories event.

Where should I append my route programmatically?
 Topic: form not repopulating
form not repopulating [message #64503] Tue, 04 November 2008 07:46
adonis827  is currently offline adonis827
Messages: 17
Registered: October 2006
Junior Member
hi there!

i have upgraded my symfony installation to 1.1 from pre 0.9 version. repopulation of form after input invalidated used to work. now i have compat10 set to on and i have an update function with its corresponding validate/update.yml. the error messages seem to be triggered right but repopulation no longer works. what gives?
 Topic: Problem with unique validator which must allow several NULL values
Problem with unique validator which must allow several NULL values [message #64535] Tue, 04 November 2008 14:10
polix  is currently offline polix
Messages: 35
Registered: September 2008
Member
Hello,

In an AuthorForm class, I have a name field. The user can enter a name or leave the field blank, so the name is NULL.
I want the name, if provided, to be unique, so in the AuthorForm class, I have:

$this->validatorSchema->setPostValidator(
      new sfValidatorAnd(array(
        new sfValidatorPropelUnique(array('model' => 'Author', 'column' => array('name'))),



The problem is that the user can't leave blank the name for more than one author because NULL is considered like a valid name and consequently it is impossible to have several authors with no name.

How to apply the unique rule only when not NULL, and leave NULL otherwise?

[Updated on: Tue, 04 November 2008 14:12]

 Topic: Problem with recaptcha widget
Problem with recaptcha widget [message #64553] Wed, 05 November 2008 02:50
gnx_  is currently offline gnx_
Messages: 8
Registered: September 2008
Location: Finland
Junior Member
So I just made a little test to try out the recaptcha widget.
My form only consist of a single of those widgets like so:

<?php
class RoboCheckForm extends sfForm
{

 
  public function configure()
  {
    $this->widgetSchema['recaptcha'] = new sfWidgetFormReCaptcha(array(
  'public_key' => 'xxx'
));
 

$this->validatorSchema['recaptcha'] = new sfValidatorReCaptcha(array(
  'private_key' => 'xxx'
));
 
  }
}
?>


and here is my action

class botcheckActions extends sfActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex($request)
  {
    $this->form = new RoboCheckForm;

  if ($request->isMethod('post'))
    {
	$captcha = array(
  'recaptcha_challenge_field' => $request->getParameter('recaptcha_challenge_field'),
  'recaptcha_response_field'  => $request->getParameter('recaptcha_response_field'),
  );
      $this->form->bind($captcha);
      if ($this->form->isValid())
      {
		 $this->redirect('botcheck/human');
      }
	  $this->redirect('botcheck/fail');
    }

}
}


The problem is the form never passes validation.
I've looked up the request and challenge/response fields are being sent with approriate values. I've also double-checked the api keys.

So there is clearly something I'm missing, but what?
 Topic: Search functionnality in a 1.1 project
Search functionnality in a 1.1 project [message #64569] Wed, 05 November 2008 12:46
jarod51  is currently offline jarod51
Messages: 79
Registered: May 2006
Member
Hi

I used to install sfLucenePlugin in my 1.0 projects. Now it's deprecated for 1.1 and 1.2 projects.

I've searched in the plugin repository and found sfPropelZSLSearchPlugin -> install.

Now i'm trying to use it but i don't have any task available to initiate/configure it Sad

Help please...

And are there any other solutions for inserting a search module in an application ? How do you achieve that ?
 Topic: sf 1.2 helpers - Linktolist help required.
sf 1.2 helpers - Linktolist help required. [message #64576] Wed, 05 November 2008 13:42
fredlab  is currently offline fredlab
Messages: 16
Registered: December 2007
Junior Member
Hi,

I am triyng the new admin generator and I modified the _list_td_actions to add an actions for each author to provide a link to its list of articles.

I found the linkToList($params) helper but I cannot get it to work.

If anyone can help ?

Regards,

Fredlab.
 Topic: [SOLVED]:Link_to Problem
[SOLVED]:Link_to Problem [message #64584] Wed, 05 November 2008 15:50
Shawnstein  is currently offline Shawnstein
Messages: 61
Registered: April 2008
Member
Hello,

i have a problem width a link_to function:

i want to use a link to delete something:

<?php use_helper('Url'); ?> 
<?php echo link_to('delete', '@upload_delete?id=1'); ?>


but in the output the key=id and the Value doesn't work

output:

<a href="upload/upload_delete">delete</a>


but it must be:

<a href="upload/upload_delete/id/1">delete</a>


why this doesn't work? whats my Fault?

i forgot to define it in the routing.yml:

upload_delete:
  url:   /upload/upload_delete/:id/:code
  param: { module: upload, action: uploaddelete }

[Updated on: Wed, 05 November 2008 15:58]

 Topic: problem: AJAX, I18N and getXXXsRelatedByXXXId in template
icon9.gif  problem: AJAX, I18N and getXXXsRelatedByXXXId in template [message #64592] Wed, 05 November 2008 20:19
volod  is currently offline volod
Messages: 85
Registered: June 2008
Member
Hello,

I have one action that is invoked as a static link (page) and via AJAX. That action retrieves
Category
data from DB with
CategoryPeer::doSelectWithI18n($crit)
. It is has I18N and subcategories (objects of the same class).
The problem is:
subcategories are retrieved by
$category->getCategorysRelatedByCategoryId($subCategoryCrit)
method in template. If page is opened as a static page everything is fine and each subcategory has i18n data, but! if AJAX is used then parent objects (categories) contain i18n data, but not subcategories.

Is it a bug in symfony? I've checkouted latest symfony 1.1 from svn, but no luck Sad

Thank you!
Vladimir


Vladimir Bilyov Websites development and support, Design, SEO
 Topic: sf 1.1 form: secure & required fields problem
sf 1.1 form: secure & required fields problem [message #64596] Wed, 05 November 2008 22:46
volod  is currently offline volod
Messages: 85
Registered: June 2008
Member
Hello,

I have some fields that shouldn't even appear on a form (even in hidden), but these fields are required (NOT NULL) by DB. These fields values should be updated only in
executeUpdate


How do I insert &/or update these fields values?
I did a small hack setValue that updates form value in executeUpdate method, but it doesn't work if there's no such field in form (and I don't really like that solution)

just a small example:
Test:
  title: varchar(32)
  description: varchar(255)
  secure_field: {type: varchar(32), required: true}


secure_field should never appear in Form, but it should be editable in executeUpdate fucntion

Thank you!

[Updated on: Thu, 06 November 2008 08:51]


Vladimir Bilyov Websites development and support, Design, SEO
Pages (169): [ «  <  4  5  6  7  8  9  10  11  12  13  14  15  16  17  18  19  >  »]

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