Skip to content

Instantly share code, notes, and snippets.

@hailwood
Created September 19, 2014 03:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hailwood/36ff00bf788152912d01 to your computer and use it in GitHub Desktop.
Save hailwood/36ff00bf788152912d01 to your computer and use it in GitHub Desktop.
<?php
class BlogHolder_ControllerExtension extends DataExtension {
public static $allowed_actions = array('ArticleSearchForm', 'search');
public function ArticleSearchForm() {
// Create fields
$categories = array();
foreach($this->owner->BlogCategories() as $category){
$categories[$category->ID] = $category->Title;
}
$keywordField = new TextField('Keyword', 'Keywords:');
$keywordField->setAttribute('placeholder', 'Keywords');
$fields = new FieldList(
$keywordField,
new DropdownField('Category', 'Category:', $categories)
);
// Create actions
$actions = new FieldList(
new FormAction('search', 'Search')
);
return new ArticleSearchForm($this->owner, 'search', $fields, $actions);
}
public function search($data, $form){
die('<pre>');
var_dump($data, $form);
die('</pre>');
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment