Author Archive for Kamil Adryjanek

Symfony 1.2 - using sfForm with jquery validation plugin - part 2

New jQuery 1.3 and its user interface have a lot of great features. But if we want to use our jQuery validation plugin with 1.3 version we need to upgrade plugin version to 1.5.1 (or higher), which is still compatible with 1.2.6. New Validate Plugin version (1.5.2) came up with some nice features like integration with UI Tabs. The following example shows a real implementation of user profile form divided in three sections.
Continue reading ‘Symfony 1.2 - using sfForm with jquery validation plugin - part 2′

Symfony 1.2 - sfForm - unsetAllExcept - better way?

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]);
  	}
  }

?>

Symfony 1.2 and multipage form - wizard

This time i want to give you simple example about how to create multipage (wiazard) form using great Symfony 1.2 form framework. It would be simple 3 steps registeration form with validation after each step. In this example i’m using propel but it would also work great wiht Doctrine. Lets start!

First, we need to start a new project, create frontend application and multiPageForm module (from the command line prompt):

symfony generate:project multipageFormApp

symfony generate:app frontend

symfony generate:module frontend multiPageForm

Continue reading ‘Symfony 1.2 and multipage form - wizard’

Symfony i Zend Framework

Celowo nie chciaÅ‚em tytuÅ‚ować wpisu Symfony vs Zend Framework bo wpisów o podobnej tematyce jest bardzo dużo. Jedne mniej, drugie bardziej konkretne i sensowne. Można siÄ™ spierać który z tych dwóch frameworków jest lepszy, jednak tak naprawdÄ™ pytanie brzmi, który jest dla nas bardziej odpowiedni, intuicyjny i z którym bÄ™dzie Nam siÄ™ lepiej pracowaÅ‚o. Ogólnie rzecz biorÄ…c bardzo drażniÄ…cÄ… sprawÄ… sÄ… wszelkie kłótnie: “który framework lepszy?”, “który wybrać”, “Zend Framework vs Symfony” - wszystko zależy od wymagaÅ„ projektu i programisty. Porównanie tym bardziej jest trudne, że Zf i Sf z zaÅ‚ożeÅ„ oferujÄ…c podobne możliwoÅ›ci, sÄ… zupeÅ‚nie różne. PostanowiÅ‚em wiÄ™c przedstawić moje skromne zdanie.

Z góry zaznaczam, że nie będę tutaj pisał nic o Cake PHP, CodeIgniter czy Kohanie. Nigdy nie miałem okazji pracować z żadnym z tych frameworków i w najbliższym czasie nie przewiduje, żeby coś w tym temacie się zmieniło.

Poniżej postaram się krótko i konkretnie przedstawić moje osobiste przemyślenia na ten temat, na podstawie własnych doświadczeń jakie mam w pracy z Sf i ZF. Wszelkie uwagi i opinie są bardzo mile widziane.
Continue reading ‘Symfony i Zend Framework’

Symfony 1.2 - tasks and cron

I was wondering if there is any simple way in Symfony for calling cron job. I found in the documentation that we can use Batch files - it is kind of PHP script that looks similar to symfony front controller, all we need to do is to initalize symfony, parse project and application Configuration. Quite cool but there is better way (just in my opinion) to access all symfony features from the command line: tasks.
Every time we are creating project, generating modules, building models/forms we use standard symfony tasks. Task are grouped by namespace and name - this allows us to build intuitive script names. For example namespace: propel or doctrine, and the task name: build-model, build-sql. Why we should use tasks instead of batch files? Tasks are really simple, powerful and they take care of parsing command line arguments and options, initalizing needed configuration and classes. To create a simple task we have to create a class that exetend sfBaseTask and put it into lib/task/ directory. File name must ends with “Task.class.php” to be properly loaded.
Another great thing about tasks is that Symfony also provide task for generating new, custom tasks :)
Continue reading ‘Symfony 1.2 - tasks and cron’

Symfony + jQuery Flexigrid

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’

Symfony 1.2 - sfForm - Yet another useful function

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’

Symfony 1.2

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′

Symfony 1.1 - editing uploaded file with sfForm

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’

Zend Framework - integracja z Doctrine ORM

Korzystając z Symfony bardzo spodobała mi się praca z Propelem i Doctrine (bardziej do gustu przypadło mi jednak Doctrine). Jako że domyślny silnik bazodanowy Zenda pozostawia wiele do życzenia, postanowiłem go zamienić na Doctrine. Osoby, które jeszcze nie spotkały się nigdy wcześniej z Doctrine zapraszam na stronę projektu - znajdziecie tam wszystkie niezbędne informacje.
Continue reading ‘Zend Framework - integracja z Doctrine ORM’




About me:

  • PHP programmer
  • Symfony developer
  • Zend framework developer

Categories: