Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [PHP]wysylanie formularza code igniter
eminiasty
post 9.09.2017, 16:18:26
Post #1





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

Ostrzeżenie: (0%)
-----


W php strukturalnym wysylalem formularz np. w ten spsosob:
  1. <div class="col-xs-8">
  2. <input type="hidden" name="set" value="1" />
  3. <input type="submit" class="btn btn-primary" value="cosik" >
  4. </div>


  1. if(isset($_POST['set']) && ($_POST['set'])==1) {


W code igniter gdy chce zrobic tak:
  1. <div class="btn-group">
  2. <input type="hidden" name="edit" value="1"/>
  3. <input type="submit" class="btn btn-primary" value="Zapisz i wyjdź" >
  4. </div>
  5. <div class="btn-group">
  6. <input type="hidden" name="a" value="1"/>
  7. <input type="submit" class="btn btn-success" value="Zapisz zmiany" >
  8. </div>

  1. if ($this->form_validation->run() == true) {
  2. if($this->input->post('edit') && $this->input->post('edit') ==1 ) {
  3. ...

dzialaja mi oba przyciski, gdzie powinien tylko pierwszy? dlaczego tak jest?
Go to the top of the page
+Quote Post
trueblue
post 9.09.2017, 16:31:19
Post #2





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1827
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


Bo są w tym samym formularzu.
Albo rozdziel na dwa formularze, albo zapoznaj się z atrybutem formaction.


--------------------
Go to the top of the page
+Quote Post
eminiasty
post 9.09.2017, 16:36:57
Post #3





Grupa: Zarejestrowani
Postów: 267
Pomógł: 0
Dołączył: 11.09.2015

Ostrzeżenie: (0%)
-----


  1. <form method="POST" action="backend/categories/form">
  2. <input type="text" name="title" value="" />
  3.  
  4. <button type="submit" name="submitForm" value="formSave">SAVE</button>
  5. <button type="submit" name="submitForm" value="formSaveNew">SAVE AND ADD NEW</button>
  6. </form>


  1. $formSubmit = $this->input->post('submitForm');
  2. if( $formSubmit == 'formSaveNew' )
  3. redirect($this->config->item('backend_folder').'/categories/form');
  4. else
  5. redirect($this->config->item('backend_folder').'/categories');


a to dobre rozwiązanie?
Go to the top of the page
+Quote Post
trueblue
post 9.09.2017, 18:27:56
Post #4





Grupa: Zarejestrowani
Postów: 6 806
Pomógł: 1827
Dołączył: 11.03.2014

Ostrzeżenie: (0%)
-----


https://www.w3schools.com/tags/att_input_formaction.asp


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 8.07.2025 - 18:53