You are here:Home
  • Narrow screen resolution
  • Wide screen resolution
  • Decrease font size
  • Default font size
  • Increase font size
  • default color
  • green color
  • blue color

Markup, style, scripting, and server-side techniques

Database aware Select elements for Zend_Form (or Extending Zend_Form_Element_Multi)

RapidPHP
Monday, 09 February 2009

In this article, you will know how you can extend select form element that comes with Zend Framework, to be easily filled with data from your database table. We want to be able to easily fill select elements from database table with less repetitive code. It's already easy to fill select elements with database data out of the box:

$db = Zend_Db_Table_Abstract::getDefaultAdapter();
$options = $db->fetchPairs(
   $db->select()->from('table_name', array('id', 'display_field'))
     ->order('some_field ASC'), 'id');
$form->getElement('someelement')->AddMultiOptions($options);

In the snippet above you get default database adapter, then simply fetch all items from 'table_name' ordering by 'some_field', and you see we fetch them as pairs binding to 'id' field. This basically means that the result of fetchPairs returns associative array of items. For select control options, we just want two fields: one for the display and one for the values ('id' is the value field, 'display_field' is for display)

But what if you have many database aware select controls? How is it possible to extend Zend Framework select elements with an easy method to populate data from database table?

Read on for details.

Last Updated ( Sunday, 03 October 2010 )

Zend_Form double escaping

Gotchas
Monday, 09 February 2009
Sometimes you might notice that with Zend Form you have quotes double escaped. This is because Zend_Form escapes your input, and so does a php binary. You really want to disable it in this case. Head on to your .htaccess and add: php_value magic_quotes_gpc off
Last Updated ( Monday, 09 February 2009 )

Debugging your ZF application with Firebug

Debugging
Sunday, 08 February 2009
Debugging your application using Firebug can be a handy substitute for using Zend_Debug::dump (). In this tutorial we are going to show you, how you can create an action helper for dumping your php variables to Firebug's console.
Last Updated ( Sunday, 29 March 2009 )

CSS and Javascript Compression

Website Optimization Techniques
Sunday, 23 March 2008

Apart from being GZIP'ed, the CSS and Javascript files can be compressed (minified) by stripping unnecessary comments and whitespaces. This allows to save even more on bandwidth and produce faster webpages than before.

GZIP Compression

Website Optimization Techniques
Sunday, 23 March 2008

It is important for a website to have GZIP compression enabled. It is able to make your pages smaller up to 7 times (!). The GZIP compression is an Apache server's feature.

<< Start < Prev 1 2 3 4 5 Next > End >>
Results 21 - 25 of 25

Vote!

Your server OS of choise
 

Login

Related Articles