schema:
----------
state:
id:
name: VARCHAR(255)
agency:
id:
name: VARCHAR(255)
state_id:
The function to sort in actions.class.php
--------------------------------------------
public function executeSort(sfWebRequest $request) {
$field_name = $request->getParameter('column');
$sortby = $request->getParameter('by');
$c= new Criteria();
if($field_name == "state_id") {
$c->addJoin(AgencyPeer::STATE_ID,StatePeer::ID,Criteria::LEFT_JOIN);
if($sortby == "asc") {
$c->addAscendingOrderByColumn(StatePeer::ABBREVIATION);
}else {
$c->addDescendingOrderByColumn(StatePeer::ABBREVIATION);
}
}else {
if($sortby == "asc") {
$c->addAscendingOrderByColumn(constant("AgencyPeer::".strtoupper($field_name)));
}else {
$c->addDescendingOrderByColumn(constant("AgencyPeer::".strtoupper($field_name)));
}
}
$this->agency_list = AgencyPeer::doSelect($c);
$this->setTemplate('index');
}
Showing posts with label Symfony Framework. Show all posts
Showing posts with label Symfony Framework. Show all posts
Wednesday, November 11, 2009
Friday, October 30, 2009
Ajax in Symfony
Changing the Content Depends upon the User Selected Value in Select Box.
-----------------------------------------------------------------------------------------
Here The Functionality is We need to get the List of Documents depends upon the Category Choosen From the Selectbox.
//actions.class.php
public function executeOpen(){
$cat_criteria = new Criteria();
$categories = CategoriesPeer::doSelect($cat_criteria);
foreach($categories as $category) {
$options[$category->getId()] = $category->getName();
}
$this->categories = $options;
}
//openSuccess.php
select_tag("category", options_for_select($categories), array("onChange" => remote_function(array(
'update' => 'docs',
'url' => 'manuals/documents',
'with' => "'id=' + \$F('category')",
))
)); ?>
< div id="docs" > < /div >
//actions.class.php
public function executeDocuments() {
$cat_id = $this->getRequestParameter('id');
$c = new Criteria();
$c->add(DocumentsPeer::CATEGORY_ID,$cat_id);
$documents = DocumentsPeer::doSelect($c);
$result = "";
foreach($documents as $document) {
$result .= "<a href='/orm/web/manuals/view/id/".$document->getId()."'>>".$document->getTitle()."<</a>><<>>";
";
//$result .= "";
}
echo $result;
return SfView::NONE;
}
-----------------------------------------------------------------------------------------
Here The Functionality is We need to get the List of Documents depends upon the Category Choosen From the Selectbox.
//actions.class.php
public function executeOpen(){
$cat_criteria = new Criteria();
$categories = CategoriesPeer::doSelect($cat_criteria);
foreach($categories as $category) {
$options[$category->getId()] = $category->getName();
}
$this->categories = $options;
}
//openSuccess.php
select_tag("category", options_for_select($categories), array("onChange" => remote_function(array(
'update' => 'docs',
'url' => 'manuals/documents',
'with' => "'id=' + \$F('category')",
))
)); ?>
< div id="docs" > < /div >
//actions.class.php
public function executeDocuments() {
$cat_id = $this->getRequestParameter('id');
$c = new Criteria();
$c->add(DocumentsPeer::CATEGORY_ID,$cat_id);
$documents = DocumentsPeer::doSelect($c);
$result = "";
foreach($documents as $document) {
$result .= "<a href='/orm/web/manuals/view/id/".$document->getId()."'>>".$document->getTitle()."<</a>><<>>";
";
//$result .= "";
}
echo $result;
return SfView::NONE;
}
Subscribe to:
Posts (Atom)