Set widget label from action file in symfony 1.4

In Action File

==========================================================

$this->form = new youFormclassname();

To set individual Label

$this->form->getWidget(‘widgetname’)->setLabel(‘widget Custom label’);

To set multiple field label

$this->form->getWidgetSchema()->setLabels(array(
‘field_name_1’    => ‘Field 1 Custom Lable’,

‘field_name_2’    => ‘Field 2 Custom Lable’,

}

++++++++++++++++++++++++++++++++++++++

In Template File

============================================

<?php echo $form[‘field_name_1’]->renderLabel() ?>

Self join criteria in symfony

For Example :
SELECT tbl1.id FROM tbl1 a LEFT JOIN tbl1 b ON a.somecolumnname = b.somecolumn ORDER BY a.somecolumn DESC

The criteria would be as follow

$c=new Criteria();
$c->addAlias(‘a’, ‘tbl1’);
$c->addAlias(‘b’, ‘tbl1’);
$c->addSelectColumn(‘b.id’);
$c->addSelectColumn(‘a.tbl1_id’);
$c->addDescendingOrderByColumn(‘a.somecolumn’);
$c->addJoin(‘a.somecolumnname’,’b.somecolumn’,Criteria::LEFT_JOIN); // Specify your criteria LEFT, RIGHT or INNER
$rs = tbl1Peer::doSelect($c);

Thanks Cheers 🙂

mysql error while executing propel:insert-sql in symfony 1.4

[propel-sql-exec] SQLSTATE[42000]: Syntax error or access violation: 106 you have an error in your SQL syntax; check the manual that corresponds to you
server version for the right syntax to use near ‘Type=InnoDB’ at line 16
>> propel Running “insert-sql” phing task
[propel-sql-exec] Failed to execute:

CREATE TABLE `tblName`
(
`id` INTEGER NOT NULL AUTO_INCREMENT,
`description` TEXT,
`image` VARCHAR(255),
`created_at` DATETIME,
PRIMARY KEY (`id`),
)Type=InnoDB

[propel-sql-exec] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘Type=InnoDB’ at line 16

Some problems occurred when executing the task:
If the exception message is not clear enough, read the output of the task for more information
>> file- D:/xampp/htdocs/s…1_4/config/generated-schema.xml

The solution to this is
Edit the file D:/xampp/htdocs/symfony_1_4/lib/vendor/symfony/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/sql/mysql/MysqlDDLBuilder.php
Line 156, change
$script .= “Type=$mysqlTableType”;
to
$script .= “Engine=$mysqlTableType”;

How to use FCKeditor in symfony

1. Download the FCKeditor source from http://ckeditor.com/download

2. Extract the source to /web/js/ directory of your symfony project directory

3. To use the editor in symfony, add (edit if present)the below line //config/settings.yml

.settings:
rich_text_fck_js_dir: js/fckeditor

4. You have to edit /web/js/fckeditor/fckconfig.js

var _FileBrowserLanguage = ‘php’ ; // asp | aspx | cfm | lasso | perl | php | py
var _QuickUploadLanguage = ‘php’ ; // asp | aspx | cfm | lasso | php

Depending on the technology you are using you have to set the above two parameter

5. In newer versions of FCKEditor you also have to enable the PHP connector in file /web/js/fckeditor/editor/filemanager/connectors/php/config.php on line 28, and also set your upload directory (on line 32).

$Config[‘Enabled’] = false;
$Config[‘UserFilesPath’] = ‘/uploads/assets/’ ;

You can set the UserFilesPath to whatever folder you want to store the uploaded file

6. Now you are ready to use the fck editor in your page

$options = array(
‘rich’ => ‘fck’,
‘height’ => 500,
‘width’ => 500,
);
echo textarea_tag(‘inputname’, ‘Lorem ipsum’, $options );

Thats All 🙂

Update query in symfony

Suppose you want to execute query like
UPDATE tableName SET column1 = ‘abc’,column2 = ‘xyz’ WHERE column =’1′;
then you can use the below syntax to do so 🙂

—————————————————————————-

$con = Propel::getConnection();

/* Here you have to set the condition for which you need to update */
$c1 = new Criteria();
$c1->add(TableNamePeer::COLUMN_NAME, $conditionForColumn1);

/* Here you have to set the column value */
$c2 = new Criteria();
$c2->add(TableNamePeer::COLUMN_TO_UPDATE, $value);

BasePeer::doUpdate($c1, $c2, $con);

How to set the meta tag information intemplate file in symfony

You can set the meta tag information in your template file as below.

sfContext::getInstance()->getResponse()->setTitle(‘Your meta title here’);
sfContext::getInstance()->getResponse()->addMeta(‘description’,’ Meta description information’);
sfContext::getInstance()->getResponse()->addMeta(‘keywords’,’meta tag keywords seperated by commas’);

That’s it.

Thanks