Yii Framework Forum: BeginForm -- several calls of Controller methods - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

BeginForm -- several calls of Controller methods [solved]

#1 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 20-April 17
  • Location:Hannover

Posted 04 March 2018 - 10:14 AM

hi guys, following code will create two html elements: Once a button, second a textinputField:
 <?= Html::submitButton('<span class="glyphicon glyphicon-trash"></span>', ['title' => 'Records löschen', 'name' => 'button_checkBoxes']); ?>
<?=

Html::textInput('Searching', 'Search for Mails', ['name' => 'SearchForMail', 'class' => 'form-control input-sm']);?>



My question: How to define static method beginForm of class Html in order to get two different methods in Controller rendered?
submittbutton should render method all($fk) in Controller,
textinput should render MailSearching($p1,$p2) in Controller

This is current status of beginForm()

?><?=
Html::beginForm(['/dateianhang/dateianhang/all', 'fk' => $id], 'post', ['name' => 'idAnhang']);
.
.
$gridColumn = [
.
.
];

<?=
GridView::widget([
.
.
];

<?=
Html::endForm();


0

#2 User is offline   softark 

  • Keep It Simple
  • Yii
  • Group: Moderators
  • Posts: 3,642
  • Joined: 16-February 11
  • Location:Japan

Posted 04 March 2018 - 05:43 PM

A html form can not have 2 or more target actions. You have to use a javascript to do that.

I would probably do it like the following:

1. Add a jQuery "on change" event handler to the text input.
2. Submit an ajax call to "mail search" action from the event handler.
3. And update the relevant fields using the response.

Do I understand your question right?
0

#3 User is offline   tklustig 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 419
  • Joined: 20-April 17
  • Location:Hannover

Posted 04 March 2018 - 07:34 PM

View Postsoftark, on 04 March 2018 - 05:43 PM, said:

A html form can not have 2 or more target actions. You have to use a javascript to do that.

I would probably do it like the following:

1. Add a jQuery "on change" event handler to the text input.
2. Submit an ajax call to "mail search" action from the event handler.
3. And update the relevant fields using the response.

Do I understand your question right?


Okay. Alternatively, I also could give parameter to Controller, so that I can decide,which part of code has to be done.
I think, I will do so,'cause AJAX is overhead for this case.
Bye & thanks for ur answer!
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users