Skip to content

Instantly share code, notes, and snippets.

View andreia's full-sized avatar
❤️
coding

Andréia Bohner andreia

❤️
coding
View GitHub Profile
date("d/m/Y", mktime(0, 0, 0, date("m"), date("d")+5, date("Y"))); // formato DD/MM/AAAA - data atual + 5 dias
@andreia
andreia / gist:716935
Created November 26, 2010 16:39
Change the default required and invalid error messages
// symfony 1.2
public function setup(){
sfValidatorBase::setRequiredMessage('O campo é obrigatório');
sfValidatorBase::setInvalidMessage('O campo é inválido');
parent::setup();
}
// symfony 1.4
$(function(){
$("#frmCadastro").relatedSelects({
onChangeLoad: 'retornaDados.php',
loadingMessage: 'Carregando, por favor aguarde...',
selects: ['cenId', 'curId', 'disId'],
disableIfEmpty: true,
onEmptyResult: function(){
alert('Não existem opções disponíveis para ' + $(this).find('option:selected').text() + '!');
}
});
<?php
class MyFormFilter extends BaseMyFormFilter{
public function configure(){
$this->widgetSchema['areas_conhecimento'] =
new sfWidgetFormChoice(array(
'expanded' => true,
'choices' => Doctrine_Core::getTable('MyTable')->getAreasConhecimento(),
));
}
<?php
class MyFormFilter extends BaseMyFormFilter{
public function doBuildQuery(array $values){
$query = parent::doBuildQuery($values);
$query->leftJoin($query->getRootAlias().".Translation t");
return $query;
}
$years = range(2000, date("Y"));
$this->widgetSchema['start_date'] = new sfWidgetFormFilterDate(array(
'from_date' => new sfWidgetFormDate(array('years' => array_combine($years, $years))),
'to_date' => new sfWidgetFormDate(array('years' => array_combine($years, $years))),
'with_empty' => false,
'template' => 'from %from_date% to %to_date%',
));
$ symfony plugin:install -r 0.9.3 sfFormI18nNumberPlugin
@andreia
andreia / gist:998229
Created May 29, 2011 23:13
filter_var
<?php
// http://uk.php.net/manual/en/filter.filters.php
// validate
// http://uk.php.net/manual/en/filter.filters.validate.php
$var = filter_var($email, FILTER_VALIDATE_EMAIL);
$var = filter_var($code, FILTER_VALIDATE_INT);
// sanitize
// http://uk.php.net/manual/en/filter.filters.sanitize.php
@andreia
andreia / gist:1028347
Created June 15, 2011 23:06
Schedule a command to execute one-time
$ echo cmd | at 5am next year
@andreia
andreia / gist:1028356
Created June 15, 2011 23:13
Tweeting from shell
$ curl -u user:pass -d status='Hello from shell' http://twitter.com/statuses/update.xml