Jump to:

23483 Posts in 18965 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » Call ajax to form action

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

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

Page: 1
Go to End
Author Topic: 436 Views
  • Craftnet
    Community Member
    58 Posts

    Call ajax to form action Link to this post

    Hi, I have form like extend
    I add to function

             return $this -> renderWith("Footer");
          } else {//DO SOMETHING}

    How to call in js to this function from Form ("AddObiekt")

    When in JS add url: ajax/AddObiekt - he call to Page Controller
    I wont that AJAX in JS call to function AddObiekt from class AddObiektForm extends Form


    class AddObiektForm extends Form {
       function __construct($controller, $name) {
          $title = new TextField('Title', 'Tytuł');      
          //OTHER STAFF
          $fields = new FieldList(array(
             //OTHER STAFF
          $validator = new RequiredFields(
             //OTHER STAFF
          $actions = new FieldList($search = new FormAction("AddObiekt", _t("AddObiektForm.ADD", "Dodaj obiekt i przejdź do dodawania zdjęć")));

          parent::__construct($controller, $name, $fields, $actions, $validator);

       function forTemplate() {
          return $this -> renderWith(array(
             $this -> class,
       public function AddObiekt($data, $form) {
             return $this -> renderWith("Footer");
          } else {
          //VALIDATE BY PHP
          if ($Obiekt) {
             //DO SOMETHING
          } else {
             //DO SOMETHING         



    function tt() {
             $('#AddObiektForm_AddObiektForm_action_AddObiekt').click(function(e) {
             var $form = $("#AddObiektForm_AddObiektForm");
                var obiekt_id = $(this).data('obiektid');
                   type : "POST",
                   url: "ajax/AddObiekt",
                   data : $form.serialize()
                }).done(function(msg) {
                }).error(function(msg) {
                   alert('Błąd! Proszę spróbować ponownie lub skontaktować się z administratorem');

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.