- Open: chrome://net-internals/#httpThrottling
- Uncheck the checkbox.
- Be happy ASAP.
Friday, March 23, 2012
Solved: Chrome Error 139 (net::ERR_TEMPORARILY_THROTTLED)
Thursday, March 22, 2012
setValue() For Form Fields in Symfony
If you want to overwrite the value of a field in an action, you have to a create a new method for the form. Usually people think that setDefault method is good for that. No. setDefault set a default value to a field. However if the field contains a value, setDefault won't overwrite it. Let's see an example: You put a word to the "location" field then you save the form to the database. after that, you want to see another value in the "location" field:
// add this method to the form class public function setValue($field, $value) { // set the value for this request $this->values[$field] = $value; // override the value entered by the user $this->taintedValues[$field] = $value; // force a refresh on the field schema $this->resetFormFields(); } // actions.class.php ... save method ... if ($this->form->isValid()) { $this->form->save(); // the magic $this->form->setValue('location', 'a new value'); // you can set an empty value also $this->form->setValue('location', ''); // if location is a checkbox, you have to set null to uncheck it $this->form->setValue('location', null); ...
Wednesday, March 21, 2012
Table border-radius With CSS3
table tr:first-child td:first-child { border-top-left-radius: 5px; } table tr:first-child td:last-child { border-top-right-radius: 5px; } table tr:last-child td:first-child { border-bottom-left-radius: 5px; } table tr:last-child td:last-child { border-bottom-right-radius: 5px; }
Labels:
border-radius,
css,
css3,
table
Tuesday, March 20, 2012
Doctrine Not Save Boolean Value to Database in Symfony
If you create a boolean field in the database and symfony renders it as a checkbox ( sfWidgetFormInputCheckbox ) in the form... AND DOCTRINE DOES NOT SAVE THE VALUE TO THE DATABASE, you have to a put the boolean validator on it and doctrine will save the value. That's the magic.
$this->setValidators(array( ..., 'enabled' => new sfValidatorBoolean(), ..., ));
Monday, March 19, 2012
Friday, March 9, 2012
Get Field Comments with Doctrine in Symfony
In Action:
$t = Doctrine::getTable('Product'); foreach($t->getColumns() as $key => $column) { $comments[$key] = $column['comment']; }
Thursday, March 8, 2012
Symfony sfConfig Variables
This page was originally available here: Doggetto.com. However the page is unavailable now, thus I publish this copy.
Reference to Config Variables
- Be careful in referencing any app-specific variables in the model in a multi-app project. If they are not available in the app you are using the model function in you will have problems.
sfConfig::get('sf_config_variable', 'The default value'); // The default is optional.
Symfony Framework
sf_symfony_lib_dir
The real path to the framework’s lib directory
(/usr/share/php/symfony/symfony12/lib)
Project Structure and Layout
sf_root_dir
The path to the project root
(/var/www/project_name)
sf_apps_dir
The path to the project’s apps folder
(/var/www/project_name/apps)
sf_lib_dir
The path to the project’s lib folder
(/var/www/project_name/lib)
sf_log_dir
The path to the project’s log folder
(/var/www/project_name/log)
sf_data_dir
The path to the project’s data folder
(/var/www/project_name/data)
sf_config_dir
The path to the project’s config folder
(/var/www/project_name/config)
sf_test_dir
The path to the project’s test folder
(/var/www/project_name/test)
sf_doc_dir
The path to the project’s doc folder
(/var/www/project_name/doc)
sf_plugins_dir
The path to the project’s plugins folder
(/var/www/project_name/plugins)
sf_cache_dir
The path to the project’s plugins folder
(/var/www/project_name/cache)
sf_web_dir
The path to the project’s plugins folder
(/var/www/project_name/web)
sf_upload_dir
The path to the project’s upload folder
(/var/www/project_name/web/uploads)
Application Information
sf_app
The current application
(backend)
sf_environment
The current environment
(dev)
sf_debug
Whether debugging is enabled
(1)
Application Structure and Layout
sf_app_dir
The path to the current application
(/var/www/project_name/apps/backend)
sf_app_config_dir
The path to the current application’s config directory
(/var/www/project_name/apps/backend/config)
sf_app_lib_dir
The path to the current application’s lib directory
(/var/www/project_name/apps/backend/lib)
sf_app_module_dir
The path to the current application’s module directory
(/var/www/project_name/apps/backend/modules)
sf_app_template_dir
The path to the current application’s template directory
(/var/www/project_name/apps/backend/templates)
sf_app_i18n_dir
The path to the current application’s i18n directory
(/var/www/project_name/apps/backend/i18n)
Cache Structure and Layout
sf_app_base_cache_dir
The path to the current application’s directory in the cache
(/var/www/project_name/cache/backend)
sf_app_cache_dir
The path to the current application’s directory in the cache by current environment
(/var/www/project_name/cache/backend/dev)
sf_template_cache_dir
The path to the current application’s templates directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/template)
sf_i18n_cache_dir
The path to the current application’s i18n directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/i18n)
sf_config_cache_dir
The path to the current application’s config directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/config)
sf_test_cache_dir
The path to the current application’s test directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/test)
sf_module_cache_dir
The path to the current application’s modules directory in the cache by current environment
(/var/www/project_name/cache/backend/dev/modules)
Application Settings
You can access any value in settings.yml by prepending “sf_” to the value.sf_error_404_module
The module that contains the 404 action (default)
sf_error_404_action
The action that displays the 404 error (error404)
sf_logging_enabled
Boolean for whether logging is currently enabled (1)
sf_escaping_strategy
Whether the sfView class is using the Escaping Strategy (1)
sf_no_script_name
Whether the application is requiring the script name. (1)
sf_csrf_secret
The CSRF secret (UniqueSecret)
Also:
You can grab some information from the current context (usually in templates, but should work well enough in actions – I’d be very cautious about using these in models):sfContext::getInstance()->getActionName();
The name of the current action. Can also be called by $this->getActionName() in templates.
(my_awesome_action)
sfContext::getInstance()->getModuleName();
The name of the current module. Can also be called by $this->getModuleName() in templates.
(my_awesome_module)
sfContext::getInstance()->getModuleDirectory();
The path to the current module’s directory
(/var/www/project_name/apps/backend/modules/my_awesome_module)
Labels:
sfConfig
Thursday, March 1, 2012
Useful jQuery Tips
Check if a checkbox is checked:
if($('#checkbox').is(':checked')) ...
Check if a select option is selected:
if($('#select option:selected').length()) ...
Get the selected radio value:
$('.radio:checked').val()
Get all inputs with a classname begins with rescheck:
$("input[class^=rescheck-]").each(
function() {
alert($(this).attr('class'));
}
);
Jump to ( Scroll To ) an element:
$('html, body').animate({ scrollTop: $("#some_element").offset().top }, 500);
Checking to see if there is an attribute on an element:
var attr = $(this).attr('name');
if (typeof attr !== 'undefined' && attr !== false) {}
Clear selection on select:
$("#my_select option:selected").removeAttr("selected");
Ajax request and putting the result array into a select:
$.post("/url", function(data) {
var selected = '';
$.each(data, function(key, data) {
$('#foobar').append("");
});
});
if($('#checkbox').is(':checked')) ...
Check if a select option is selected:
if($('#select option:selected').length()) ...
Get the selected radio value:
$('.radio:checked').val()
Get all inputs with a classname begins with rescheck:
$("input[class^=rescheck-]").each(
function() {
alert($(this).attr('class'));
}
);
Jump to ( Scroll To ) an element:
$('html, body').animate({ scrollTop: $("#some_element").offset().top }, 500);
Checking to see if there is an attribute on an element:
var attr = $(this).attr('name');
if (typeof attr !== 'undefined' && attr !== false) {}
Clear selection on select:
$("#my_select option:selected").removeAttr("selected");
Ajax request and putting the result array into a select:
$.post("/url", function(data) {
var selected = '';
$.each(data, function(key, data) {
$('#foobar').append("");
});
});
Labels:
jquery
Subscribe to:
Posts (Atom)