Extend User plugin backend form in Octobercms











up vote
0
down vote

favorite












I extended the user plugin to include extra form fields:



      UsersController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'mobile' => [
'label' => 'Mobile',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
'phone' => [
'label' => 'Phone',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
]);
});


The new fields working fine, but I want to do some javascript functions before saving the form, I searched google and octobercms Javascrip API but no luck.



Please Advice,










share|improve this question






















  • hmm if you can share what kind of functions you want to do then we can help you better :)
    – Hardik Satasiya
    Nov 19 at 6:40












  • it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
    – Ya Basha
    Nov 19 at 21:30










  • I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
    – Ya Basha
    Nov 19 at 21:31










  • ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
    – Hardik Satasiya
    Nov 20 at 10:56

















up vote
0
down vote

favorite












I extended the user plugin to include extra form fields:



      UsersController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'mobile' => [
'label' => 'Mobile',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
'phone' => [
'label' => 'Phone',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
]);
});


The new fields working fine, but I want to do some javascript functions before saving the form, I searched google and octobercms Javascrip API but no luck.



Please Advice,










share|improve this question






















  • hmm if you can share what kind of functions you want to do then we can help you better :)
    – Hardik Satasiya
    Nov 19 at 6:40












  • it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
    – Ya Basha
    Nov 19 at 21:30










  • I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
    – Ya Basha
    Nov 19 at 21:31










  • ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
    – Hardik Satasiya
    Nov 20 at 10:56















up vote
0
down vote

favorite









up vote
0
down vote

favorite











I extended the user plugin to include extra form fields:



      UsersController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'mobile' => [
'label' => 'Mobile',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
'phone' => [
'label' => 'Phone',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
]);
});


The new fields working fine, but I want to do some javascript functions before saving the form, I searched google and octobercms Javascrip API but no luck.



Please Advice,










share|improve this question













I extended the user plugin to include extra form fields:



      UsersController::extendFormFields(function ($form, $model, $context) {
$form->addTabFields([
'mobile' => [
'label' => 'Mobile',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
'phone' => [
'label' => 'Phone',
'type' => 'text',
'span' => 'storm',
'cssClass' => 'col-md-6',
'tab' => 'Security Profile'
],
]);
});


The new fields working fine, but I want to do some javascript functions before saving the form, I searched google and octobercms Javascrip API but no luck.



Please Advice,







octobercms octobercms-plugins octobercms-backend






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 18 at 7:58









Ya Basha

1,01742133




1,01742133












  • hmm if you can share what kind of functions you want to do then we can help you better :)
    – Hardik Satasiya
    Nov 19 at 6:40












  • it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
    – Ya Basha
    Nov 19 at 21:30










  • I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
    – Ya Basha
    Nov 19 at 21:31










  • ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
    – Hardik Satasiya
    Nov 20 at 10:56




















  • hmm if you can share what kind of functions you want to do then we can help you better :)
    – Hardik Satasiya
    Nov 19 at 6:40












  • it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
    – Ya Basha
    Nov 19 at 21:30










  • I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
    – Ya Basha
    Nov 19 at 21:31










  • ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
    – Hardik Satasiya
    Nov 20 at 10:56


















hmm if you can share what kind of functions you want to do then we can help you better :)
– Hardik Satasiya
Nov 19 at 6:40






hmm if you can share what kind of functions you want to do then we can help you better :)
– Hardik Satasiya
Nov 19 at 6:40














it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
– Ya Basha
Nov 19 at 21:30




it is a normal JS function $('#hiddenField').val(JSON.stringify(valueOfExtendedField)); and after the execution of the script it will submit the formm
– Ya Basha
Nov 19 at 21:30












I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
– Ya Basha
Nov 19 at 21:31




I managed to do that in a frontend form as I have full control over the form, I created a button and did jQuery on click event and I did the logic inside the event function and submit the form, it worked as expected.
– Ya Basha
Nov 19 at 21:31












ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
– Hardik Satasiya
Nov 20 at 10:56






ok but seems in backend you can not control over code so not sure you are able to process hiddenField value, I understand you want to create json and need to use it in backend if you share how you intend to use this details in backend then I can help you : for ex like: storing in db table etc..
– Hardik Satasiya
Nov 20 at 10:56














1 Answer
1






active

oldest

votes

















up vote
2
down vote













Add this to your Plugin.php file:



...
use App;
use Event;

class Plugin extends PluginBase
{
public function boot()
{
if (App::runningInBackend()) {
Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
if (get_class($controller) === 'RainLabUserControllersUsers') {
$controller->addJs('/your-custom-js/file.js');
}
});
}
}

....
}





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














     

    draft saved


    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53358932%2fextend-user-plugin-backend-form-in-octobercms%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    2
    down vote













    Add this to your Plugin.php file:



    ...
    use App;
    use Event;

    class Plugin extends PluginBase
    {
    public function boot()
    {
    if (App::runningInBackend()) {
    Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
    if (get_class($controller) === 'RainLabUserControllersUsers') {
    $controller->addJs('/your-custom-js/file.js');
    }
    });
    }
    }

    ....
    }





    share|improve this answer



























      up vote
      2
      down vote













      Add this to your Plugin.php file:



      ...
      use App;
      use Event;

      class Plugin extends PluginBase
      {
      public function boot()
      {
      if (App::runningInBackend()) {
      Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
      if (get_class($controller) === 'RainLabUserControllersUsers') {
      $controller->addJs('/your-custom-js/file.js');
      }
      });
      }
      }

      ....
      }





      share|improve this answer

























        up vote
        2
        down vote










        up vote
        2
        down vote









        Add this to your Plugin.php file:



        ...
        use App;
        use Event;

        class Plugin extends PluginBase
        {
        public function boot()
        {
        if (App::runningInBackend()) {
        Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
        if (get_class($controller) === 'RainLabUserControllersUsers') {
        $controller->addJs('/your-custom-js/file.js');
        }
        });
        }
        }

        ....
        }





        share|improve this answer














        Add this to your Plugin.php file:



        ...
        use App;
        use Event;

        class Plugin extends PluginBase
        {
        public function boot()
        {
        if (App::runningInBackend()) {
        Event::listen('backend.page.beforeDisplay', function($controller, $action, $params) {
        if (get_class($controller) === 'RainLabUserControllersUsers') {
        $controller->addJs('/your-custom-js/file.js');
        }
        });
        }
        }

        ....
        }






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Nov 19 at 3:32

























        answered Nov 18 at 19:36









        Joseph Oppegaard

        398210




        398210






























             

            draft saved


            draft discarded



















































             


            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53358932%2fextend-user-plugin-backend-form-in-octobercms%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin