Send a Form, with data from the view
Created 5 years ago by cynoHi! The thing i want to achive is to send a form to a page (between two modules), with entry data from the view. Normally in php/laravel it works easily, but i just cant make it work with pyro. Hope someone can give me some advices. I'm gonna post the codes I currently have.
view.twig:
{{ form('buy_button').setValue('product_slug', product.slug)|raw }}
class ProductBuyButtonFormBuilder extends FormBuilder { protected $ajax = false;
protected $fields = [
'product_slug' => [
'type' => 'anomaly.field_type.text',
'hidden' => true,
'config' => [
"default_value" => '0'
],
],
];
protected $options = [
'redirect' => 'order'
];
protected $actions = [
'save' => [
'enabled' => false
]
];
protected $buttons = [
'buy'
];
}
controller in the other module: class OrdersController extends PublicController {
public function index()
{
return $this->view->make('hustle.module.orders::checkout');
}
}
and the other modules service provider:
protected $routes = [ 'order' => [ 'as' => 'hustle.module.orders::order.index', 'uses' => 'Hustle\OrdersModule\Http\Controller\OrdersController@index', ],
You want to post TO that route or you want to go to that route afterwards and include like the ID of the entry perhaps?
You can set the
redirect
option.