コード例 #1
0
 /**
  * LocationSearch form.
  *
  * Search form for locations, updates map and results list via AJAX
  *
  * @return Form
  */
 public function LocationSearch()
 {
     $fields = FieldList::create($address = TextField::create('address', ''));
     $address->setAttribute('placeholder', 'address or zip code');
     if (LocationCategory::get()->Count() > 0) {
         $filter = array();
         $locals = Locator::getLocations($filter, $exclude = array('CategoryID' => 0));
         $categories = ArrayList::create();
         foreach ($locals as $local) {
             $categories->add($local->Category());
         }
         if ($categories->count() > 0) {
             $fields->push(DropdownField::create('category', '', $categories->map('Title', 'Title'))->setEmptyString('Select Category'));
         }
     }
     $actions = FieldList::create(FormAction::create('', 'Search'));
     return Form::create($this, 'LocationSearch', $fields, $actions);
 }