SS 4.6 CMS Search Form GET method.

<%- if @topic_view.topic.tags.present? %>
<%= t 'js.tagging.tags' %>: <%- @topic_view.topic.tags.each do |t| %> <%= t %> <%- end %>
<% end %>

Hi.
I have such a problem.
I need to set the search form to use GET instead of POST. This will create a URL that represents the state of the form. The user who receives the URL will not need to set filters.

Here is my example:

use SilverStripe\ORM\DataObject;

class Publication extends DataObject {

    private static $singular_name = 'Publication';
    private static $plural_name = 'Publications';
    private static $db = array(
        "Title" => 'Varchar(1024)',
        "Description" => 'Text'
    );

}

class Article extends DataObject {

    private static $singular_name = 'Article';
    private static $plural_name = 'Articles';
    private static $db = array(
        "Title" => 'Varchar(1024)',
        "Description" => 'Text'
    );

}


use SilverStripe\Admin\ModelAdmin;
use SilverStripe\Forms\GridField\GridFieldConfig;

class PublicationsModelAdmin extends ModelAdmin {

    private static $managed_models = array(
        'Publication',
        'Article',
    );
    private static $url_segment = 'publications';
    private static $menu_title = 'Publications';

    protected function getGridFieldConfig(): GridFieldConfig {
        $config = parent::getGridFieldConfig();


       return $config;
    }

}

1 Like