Form action getting url instead of route and addData to view
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Form action getting url instead of route and addData to view
Hi,
I tried to create a form inside an existing template. I have the same form inside the
Here is the example code of the form:
In the
The form creates a url like this
Why is the form acting like this? How can I solve this problem?
Is there a way to add a data to the view every time I call this form?
Thanks
I tried to create a form inside an existing template. I have the same form inside the
template so I'm sure that the form works. I added the route in right page and everything else.welcome.blade.php
Here is the example code of the form:
Code: Select all
<form method="POST" action="{{ route('changecar') }}">
<select>
<option value="3">Volvo</option>
<option value="1">Saab</option>
<option value="2">Mercedes</option>
<option value="4">Audi</option>
</select>
<button type="submit">test</button>
</form>
I added the same form but it's not working.client/html/templates/catalog/detail/body-standard.php
The form creates a url like this
Code: Select all
http://127.0.0.1:8000/shop/Demo_bundle_article/%7B%7B%20route('changecar')%20%7D%7D
Is there a way to add a data to the view every time I call this form?
Thanks
-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Form action getting url instead of route and addData to view
I found the solution so I changed the form like this:
This code works but I can't understand one thing: I defined a controller inside my ext but I can't define a route for that controller. What I have to do?
I get
Code: Select all
<form method="POST" action="<?= route('changecar'); ?>">
<?= $this->csrf()->formfield(); ?>
<select>
<option value="3">Volvo</option>
<option value="1">Saab</option>
<option value="2">Mercedes</option>
<option value="4">Audi</option>
</select>
<button type="submit">test</button>
</form>
I get
Code: Select all
message: "Target [Aimeos\MShop\Context\Item\Iface] is not instantiable while building [Aimeos\Client\Html\Catalog\Detail\MyController]."
Re: Form action getting url instead of route and addData to view
The HTML clients are no Laravel controllers, only PHP classes. You can use them in your own Laravel controllers. Please have a look at the existing ones.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Form action getting url instead of route and addData to view
Is there a way to modify the view after submitting the form from the controller?
Re: Form action getting url instead of route and addData to view
The HTML client classes have a process() method that is called when data is sent through forms (you can set view data too) and the addData() method to add more data to the view (maybe based on the already set data).
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Form action getting url instead of route and addData to view
How can I understand if I'm sending data through form inside the "process" function?
Re: Form action getting url instead of route and addData to view
Use to check if the form has been posted
Code: Select all
$this->getView()->param( <input field name> [, <default value>] )
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Form action getting url instead of route and addData to view
Sorry I can't understand. I will try to explain better what I want.
I have a form. Every option of this form must execute a php function (that can be inside the process/addData functions) and display the new data without refreshing the page.
I must NOT use JQuery. Can you show me an example form and function please?
I have a form. Every option of this form must execute a php function (that can be inside the process/addData functions) and display the new data without refreshing the page.
I must NOT use JQuery. Can you show me an example form and function please?
Re: Form action getting url instead of route and addData to view
Can you post how your form looks like?
You have to use an XHR/AJAX request if you want to refresh the content without page reload. If it's not jQuery you have to use another JS library or try plain JS.
You have to use an XHR/AJAX request if you want to refresh the content without page reload. If it's not jQuery you have to use another JS library or try plain JS.
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos,
give us a star
If you like Aimeos,

-
- Posts: 44
- Joined: 24 Jun 2019, 14:46
Re: Form action getting url instead of route and addData to view
I found another way to do all this:
- I have a form
- onchange this form will make an ajax call
- the ajax call is a laravel function
- jquery will send the new data without refreshing the page
- the laravel function will store the data I need
- I have a form
- onchange this form will make an ajax call
- the ajax call is a laravel function
- jquery will send the new data without refreshing the page
- the laravel function will store the data I need