Skip to content

Instantly share code, notes, and snippets.

View andreia's full-sized avatar
❤️
coding

Andréia Bohner andreia

❤️
coding
View GitHub Profile
$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%',
));
<?php
class MyFormFilter extends BaseMyFormFilter{
public function doBuildQuery(array $values){
$query = parent::doBuildQuery($values);
$query->leftJoin($query->getRootAlias().".Translation t");
return $query;
}
<?php
class MyFormFilter extends BaseMyFormFilter{
public function configure(){
$this->widgetSchema['areas_conhecimento'] =
new sfWidgetFormChoice(array(
'expanded' => true,
'choices' => Doctrine_Core::getTable('MyTable')->getAreasConhecimento(),
));
}
$(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() + '!');
}
});
@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
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 / location.html
Created November 9, 2010 15:11
Geolocation using W3C Geolocation API - http://dev.w3.org/geo/api/spec-source.html
<html>
<head>
<title>Example: Geolocation using W3C Geolocation API</title>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true"></script>
<script type="text/javascript">
function initialize(){
var myOptions = { zoom: 8, mapTypeId: google.maps.MapTypeId.HYBRID };
var map = new google.maps.Map(document.getElementById("map"), myOptions);
@andreia
andreia / _form.php
Created September 17, 2010 03:17
form iterator - sf 1.4
<div class="ui-corner-all">
<?php foreach($form->getFormFieldSchema() as $formField): ?>
<div class="form_field_<?php echo $formField->getName() ?><?php $formField->hasError() and print ' ui-state-error ui-corner-all' ?>">
<div class="label ui-helper-clearfix">
<?php echo $formField->renderLabel(); ?>
</div>
<?php if($help = $formField->renderHelp()): ?>
<div class="help">
<span class="ui-icon ui-icon-help floatleft"></span>
$ git checkout master
$ git remote add username git://github.com/username/repo.git
$ git fetch username
$ git merge username/master
$ git push origin master
#mydiv ul {
margin-left: 0;
padding-left: 0;
display: inline;
}
#mydiv ul li {
margin-left: 0;
padding-left: 2px;
list-style: none;