Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Form Submit onChange without submit Button

Go to End

3 Posts   1128 Views


Community Member, 146 Posts

6 October 2013 at 12:02am


I have written a simple Dropdown Form with Submit Button, to change/select the page language.

Here is the code:


 * To change this template, choose Tools | Templates
 * and open the template in the editor.
class BootstrapNavbarLanguageForm extends Form {
    public function __construct($controller, $name, $fields = null, $actions = null) {
        $Laguages = array();
        foreach(LocaleGeoip::get_available_languages() as $Locale => $Language){
            $Languages[$Locale] = _t('BootstrapNavbarLanguageForm.'.$Language, $Language);

        // Create fields
        $fields = new FieldList(
            $locale = new DropdownField('Locale', "", $Languages, i18n::get_locale())
        // Create actions
        $actions = new FieldList(
            $submit = new FormAction('updateLang', _t('BootstrapNavbarLanguageForm.SUBMIT','BootstrapNavbarLanguageForm.SUBMIT'))


    public function updateLang(array $data){

        if($o_Member = Member::currentUser()) {

            $o_Member->Locale = $data['Locale'];

        Session::set('Locale', $data['Locale']);

Now I want this form to be used without the submit button. It just should submit on changing the dropdown. I know, I can work here with jQuery and that is not the problem.

But how to I create the code and the submit actions, without adding a(visible) submit button?

I can try to add an empty $action. But how do I tell the form, to use the updateLang method, when being submitted?


Community Member, 146 Posts

10 October 2013 at 1:49am

Anyone with an idea here?


Forum Moderator, 1391 Posts

10 October 2013 at 2:26am

Why not make the action (button) invisible using css?