domingo, 16 de março de 2014

EmbedForm with new relation

To insert new attributes to a Product in the default form we just need those few steps:

In the productForm class create the relation with the attribute form.

public function configure() {
    /* Create embedForm with an empty attribute */
    $new_attribute = new ProductAttribute();
    $this->embedForm('new_attribute', new ProductAttributeForm($new_attribute));
    $this->embedRelation('Attributes', new ProductAttributeForm());

...and we rewrite the saveEmbeddedForms methods
public function saveEmbeddedForms($con = null, $forms = null) {
    try {
        $new_attribute_form = $this->getEmbeddedForm('new_attribute');
        $values             = $this->getValue('new_attribute');

        /* Validations Rules to save the relation */
        if (empty($values['attribute_id'])) {
    } catch (InvalidArgumentException $e) {
    return parent::saveEmbeddedForms($con, $forms);

quarta-feira, 12 de março de 2014

Oracle extension oci8 in PHP5

Install OCI8 on PHP

pecl    - sudo apt-get install php-pear
phpize  - sudo apt-get install php5-dev

1. Download "Oracle Instant Client Basic and SDK" from
2. Extract the content of both archives to /etc/opt/oci8/
3. Go to /etc/opt/oci8/ and find the file called*.* (e.g. and create a symbolic link called
    . sudo ln -s
4. Install the package libaio-dev
    . sudo apt-get install libaio-dev
5. Install now the oci extension:
    . sudo pecl install oci8
        . when prompt insert the path to the path to instantclient: instantclient,/etc/opt/oci8/
    Build process completed successfully
    Installing '/usr/lib/php5/20121212/'
    install ok: channel://
    configuration option "php_ini" is not set to php.ini location
    You should add "" to php.ini
6. Locate your php.ini and add the line ""

terça-feira, 4 de março de 2014

Git color

Edit your ~/.gitconfig and add the followind lines:

[color "status"]
added = green
changed = red bold
untracked = magenta bold
[color "branch"]
remote = yellow
diff = auto
status = auto
branch = auto
interactive = auto
ui = true
pager = true