Hi Group.
I’m about to announce release of 4.2.1. Here are the list of changes since the last stable 4.2.0 release:
- api->url() handles https:// schema better
- dsql will now accept field objects as an argument.
$q->where(‘user_id’,$user->getElement(‘id’));
this will produce a query like this: “…. where user_id=`user`.id “, which is a great way to build references between models. Another example:
$model->addCondition(
$model->getField(‘age),
‘>’,
$model->getField(‘salary’)
);
This will limit model scope to only records whose “age” field is less than “salary”.
- added refSQL
When you have a model, you can use ref() to traverse it’s values. For example:
$book->load(1);
$chapters = $book->ref(‘Chapter’);
echo “Total chapters: “.$chapters->count();
calling ref() on model with no loaded record will produce error. What if we are willing to iterate through ALL the books and for each book print number of chapters? We would need to define a new field as expression:
$book->addExpression(‘chapter_count’)->set(function()use($book){
return $book->refSQL(‘Chapter’)->count();
});
in this case, the closure will be called at the time of query building (once) and instead of adding “where book_id=1” it will add “where book_id=
book.id”. This query makes perfect sense as a sub-query and will produce the
expected results.
- added Vertical Menu template
Normally, you would add a horizontal menu to your page:
$page->add(‘Menu’)->addMenuItem(‘test’)->addMenuItem(‘test2’);
The Menu view draws its template from menu.html <?Menu?> tag by default. You can change that with 4th argument to specify a template for vertical menu instead:
$page->add(‘Menu’,null,null,array(‘menu’,’MenuVertical’));
while functionally identical, this template is useful when you want to put menu on the side. Remember that you can always use your own templates with any stock views.
- field->display() works better with refereces (hasOne)
- addOns can be used for fields $form->addField(‘myaddon/fieldx’);
- method view->addClass(‘current’) is now complimented by removeClass() method. It will remove classes previously added by addClass()
- view->setModel(‘User’,false); now can be used to bind controller but don’t import any fields
- now possible again to use js() function in add-ons
- you can now add tool-tip icon into form’s field.
$form->getElement(’name’)->add(’Tooltip’,null,’after_label’);
you would need to provide your own Tooltip view class though.
- isSubmitted can be called twice without bad side-effects.
- ever wondered how to use field aliases?
$user->addField(’name’); // name of the user
$user->join(‘address’)->addField(‘address_name’,’name’); // physical “name” field from table “address” will appear inside model as “address_name” field.
- fixed some cases with Model with join where extra conditions were applied during update.
- when used in foreach($model as $row){ the “beforeLoad” hook is called only once now, not at every row. It will also receive the query as argument. afterLoad is called on each iteration.
- now bundles jquery 1.7.2 and jquery-ui 1.9-pre
- issues fixed: #49, #46, #47, #51, #52, #53
The release procedure
If your favorite bug is still not addressed, please submit either a pull request or at least mention it here. The “master” on our github repo will continue to advance after the release. The branch 4.2 will be updated to point to the current stable release (4.2.1).
Regards,
Romans