It’s kind of update of function: unsetAllExcept. Lately I had a problem with unsetting some default widgets. Using for example propel and relations m-n, auto-generated forms have widgets that cannot be unsets using the current version of function - it only unset widgets by form object fields.
I think it could be useful:
<?php
/**
* unset all fields except given parameters
*
* @param array $fields Array of fields
*/
public function unsetAllExcept($fields = array())
{
$tmp = array_keys($this->widgetSchema->getFields());
foreach(array_diff($tmp, $fields) as $value){
unset($this[$value]);
}
}
?>
Nothing special but some of you had problems putting it together. So, i decided to write simple tutorial describing how to use jquery Flexigrid with Symfony. I will use the same data as in the tutorial: Zend Framework + Doctrine + jQuery Grid . Eveything will be the same, except that we will use Symfony instead of Zend.
First we need to create new symfony project:
symfony generate:project someProjectName
or simply download sf_sandbox.
Next step is to create symfony app:
symfony generate:app frontend
Then we need one module, for example “grid”:
symfony generate:module frontend grid
Continue reading ‘Symfony + jQuery Flexigrid’
Build-in symfony form validation is really great feature. Using Propel or Doctrine ORM we have simple validation by default which we can modify in simple way.
But sometimes we want something more than server side validation (later in post SSV) and then we can easliy use javascript. Client side validation (CSV) is nice and useful but we need to remember that it could be easily switched off. So SSV is always required.
Let’s begin.
I’m not going to build a whole application. I just want to show you how to create simple contact form, validate it using SSV and CSV (with jQuery) and save it.
First of all we need to create new symfony app. If we have symfony already installed on our PC, we can just create new project directory, for example sfSimpleApp and then call:
<?php
symfomy generate:project sfSimpleApp
?>
Remember that you need to write symfony tasks in command line (on windows -cmd prompt).
As it is a simple example we are not going to configure a web server.
Continue reading ‘Symfony 1.2 - using sfForm with jquery validate plugin’
Working on my new project i really need to find a good solutions for unsetting many fields in easy way. I don’t really like philosophy of unsetting each element that i don’t need. Sometimes when i add new fields to my tables i must remember to unset (all) that fields in my Forms - really irritating:) Finally i found a solution which is working really good for me - it’s nothing special but really helpfull.
Continue reading ‘Symfony 1.2 - sfForm - Yet another useful function’
Już praktycznie od tygodnia dostępna jest nowa wersja świetnego (przynajmniej w mojej opinii) frameworka dla PHP. Nie będę tutaj wychwalał wszystkich zalet tego frameworka - po szczegóły odsyłam na stronę projektu Symfony , wymienię jednak kilka najbardziej istotnych zmian:
-w wersji 1.1 mogliśmy przetestować nowy, w pełni obiektowy framework dla formularzy, w 1.2 został on poprawiony i ulepszony (zagnieżdżone formularze są teraz naprawdę zagnieżdżone, wywołanie metody save na formularzu wywołuje save na podformularzach, nowe widgety m.in. sfWidgetFormChoice i walidatory);
Continue reading ‘Symfony 1.2′
Lately, i a had problem with editing uploaded file.
I had an object with field “photo” that was linking to the uploaded image.
When I was editing the object and leaving the input file blank (not selecting any other image) the form saved NULL in database.
I was looking for solution on many forums and in documentation but i didn’t found anything that could help me.
Finally, i solved the problem (maybe it’s not the best way, but it’s working really good).
Continue reading ‘Symfony 1.1 - editing uploaded file with sfForm’
Najświeższe komentarze