Archive for July, 2009
how to add a rich date widget in forms symfony 1.2
$this->widgetSchema['date'] = new sfWidgetFormJQueryDate();
this is helpful
setting a boolean filter field in the forms framework symfony 1.2
$this->widgetSchem['active'] = new sfWidgetFormChoice(array(‘choices’ => array(” => ‘yes or no’, 1 => ‘yes’, 0 => ‘no’)));
$this->validatorSchem['active'] = new sfValidatorChoice(array(‘required’ => false, ‘choices’ => array(”, 1, 0)));
How to access the output of an action/template in that action symfony 1.0
public function executeOdt(sfWebRequest $request)
{
$output = $this->getController()->getPresentationFor('ModuleName', 'xmlcontent');
}
> that will assign the output of executeXmlcontent() to $output
if your in a peer class, use this :
$output = sfContext::getInstance()->getController()->getPresentationFor('yourModule','yourAction');
how to hardcode a filter in admin generator action symfony 1.2
protected function getPager()
{
$c = new Criteria();
$c->add(FpUnitToPropertyPeer::PROPERTY_ID, $this->getUser()->getAttribute('property_id'));
$aUnits = FpUnitToPropertyPeer::doSelect($c);
if($aUnits){
foreach($aUnits as $u)
$aUnitIds[] = $u->getUnitId().' ';
}
else{
$aUnitIds = array();
}
$c = $this->buildCriteria();
$c->add(FpUnitPeer::ID, $aUnitIds, Criteria::IN);
$pager = $this->configuration->getPager('FpUnit');
$pager->setCriteria($c);
$pager->setPage($this->getPage());
$pager->setPeerMethod($this->configuration->getPeerMethod());
$pager->setPeerCountMethod($this->configuration->getPeerCountMethod());
$pager->init();
return $pager;
}
how to add a custom filter and disable the current filter in generator.yml
list:
firstname: { filter_criteria_disabled: true }
lastname: { filter_criteria_disabled: true, filter_is_empty: true }
title: User list
display: [ =username, _name, created_at, last_login ]
filters: [ username, _firstname, _lastname ]
Adding a style sheet in the module level view.yml
I was having a problem when I added the view.yml on the module level, it would override all style sheets in the app level
the way i fixed this was to change the top level declaration ‘default’ to ‘all’ in the app level view.yml
>>>
all:
http_metas:
content-type: text/html
……………………..
………………
….
Leaving the “default” in the module level view.yml
<<<
For instance, if your application `view.yml` stipulates:
default:
stylesheets: [main]
And if you have, in your module `config/view.yml`:
indexSuccess:
stylesheets: [special]
all:
stylesheets: [additional]
Then the `<head>` of the resulting `indexSuccess` view will show:
[php]
<link rel=”stylesheet” type=”text/css” media=”screen” href=”/css/main.css” />
<link rel=”stylesheet” type=”text/css” media=”screen” href=”/css/additional.css” />
<link rel=”stylesheet” type=”text/css” media=”screen” href=”/css/special.css” />
How to enable the sfCompat10 plugin symfony 1.2
This proceedure is not so much as enablng the mode but removing
‘sfCompat10Plugin’
from
$this->enableAllPluginsExcept(array(‘sfDoctrinePlugin’, ‘sfCompat10Plugin’));
in the config/ProjectConfiguration.class.php
Handling Images with Symfony s1.0
if ($this->getRequest()->hasFiles()){
foreach ($this->getRequest()->getFileNames() as $fileName)
{
$fileSize = $this->getRequest()->getFileSize($fileName);
$fileType = $this->getRequest()->getFileType($fileName);
$fileError = $this->getRequest()->hasFileError($fileName);
$theFileName = $this->getRequest()->getFileName($fileName);
$uploadDir = sfConfig::get('sf_upload_dir');
$this->getRequest()->moveFile('image', "images/$theFileName");
}
}