Hallo to all,
Creating a Form and Passing the data to Controller without having a Modal or database behind it, is it possible?
If an example would be great.
Thank you guys.
Hallo to all,
Creating a Form and Passing the data to Controller without having a Modal or database behind it, is it possible?
If an example would be great.
Thank you guys.
You could create a view with your data in input fields inside a form and do a simple submit, in the Controller you can get the values via $_POST or $_GET.
I do not know, if this is you are looking for.
View
<?php
echo CHtml::form($this->createUrl('testAction'), 'post');
echo CHtml::textField('field_data1', 'This the data for field_data1');
echo CHtml::hiddenField('field_data2', 'Hidden Data');
echo CHtml::submitButton('Submit');
echo CHtml::endForm();
?>
Controller
public function actionTestAction() {
$data1 = Yii::app()->getRequest()->getPost('field_data1');
$data2 = Yii::app()->getRequest()->getPost('field_data2');
}
![]()
I have realized that the question was for Yii 2.0, and my code is for Yii 1.1, but maybe it can help you to find the correct answer on Yii 2.0
![]()
Use [font=“Courier New”]Html[/font] helper class instead of [font=“Courier New”]CHtml[/font] as mentioned to generate your fields. In your controller read [font=“Courier New”]$_POST[‘field_name’][/font] to get each field.
Thank you guys
onr more question
yii2 listView ist having a $index variable, how can i make use of it ?
thanks
Open new thread fro that!