Thursday, January 1, 2009

P4A Table, a delete row helper

Sometimes, when I work with P4A, I prefer to allow the deletion of a record with a click on the table row. Look at this screenshot to have an idea:

Doing that with P4A is not hard: you have to add an action col, intercept the afterClick event and then call the db_source deleteRow event. Yet now it's even simpler because we have added the addDeleteRow helper to the P4A core :


If you want you can also call the helper with a custom label col and a custom confirmation message:

$mytable->addDeleteRow('Delete Row','Do you want to delete this row?');

You can find this helper in the svn repository or you can copy and past my code in the libraries directory:

function P4A_Table_addDeleteRow($table$params)  
    if (isset(
$params[0])) {
$col_label $params[0];
    } else {
$col_label 'Delete';
    if (isset(
$params[1])) {
$message $params[1];
    } else {
$message 'Delete current element';                   



Happy P4A hacking!

Sunday, December 28, 2008

P4A 3.2 is out!

Yes, P4A 3.2 is finally out!

The Changelog is really long but there are 3 big news to focus on:
  1. P4A is now released under LGPL 3. This means more flexibility for developers and customers.
  2. A new widget, the P4A_Grid, has been added to fast table data editing.
  3. P4A_Simple_Edit_Mask has been added to quickly create a simple mask to edit a database table.

To download P4A 3.2 visit:

Happy P4A hacking :)

Saturday, October 11, 2008

Big news for the incoming P4A 3.2

Yes, big news for the incoming P4A 3.2

I've just finished to commit the first beta release of a new widget: the p4a_grid.
What is it? It's simply an editable table. This widget has been for a lot of time a highly requested feature so now I'm really happy to have it :) There's a lot of work to be done to have the perfect widget, for example to add checkbox cells and combo box cells, but now it already does a good job.

Using the p4a_grid is similar to using the p4a_table:

$this->build("p4a_grid", "grid")
->setVisibleCols(array("product_id", "model", "date_arrival", "category", "brand"));

Now you have two options:

1) Using the "autosave" method to save automatically the changed values to database


2) Intercepting the onChange event if you need to add more complex business logic:

function myhandler($obj,$params){
$params[0] -> the primary key value
$params[1] -> the column name
$params[2] -> the formatted new value
$params[3] -> the unformatted new value

If you want to try it checkout it from svn and please give me your feedback :)

Sunday, July 20, 2008

Some unuseful things you have to know about me

  1. This is not a personal blog but a technical blog, so probably this is a really no- interesting blog for "normal" people (read no-nerd people)
  2. I'm a Web Developer (or a Web Architect when I want to show-off :P ) so you can read here about Web, PHP and similar amenities.
  3. I'm a free-software-aholic: poor you, I'll speak you about Rocco Linux and his brothers .
  4. I'll write a lot about my project P4A. If you don't know P4A you are bad and evil, and probably you have also the worst breath in the Universe :)
  5. I'll write also about community, the free Moodle hosting, free like free beer, free like free speech. If you want to start a free course you can get a free account and start to teach for free. Yes, I know, I'm also free-aholic!
  6. I founded with my friend Fabrizio CreaLabs, the smallest and coolest web/floss agency in the world :) So you know now who call for your next idea.
  7. I you really don't want to read about technical stuff and you understand Italian you can try to read about my "philosophical" and political ideas in my boring amazing blog
  8. Of course you've already guess that: English is not my native language and I always been the worst student in all my language classes so please be patient with me.
  9. Cheers :)